How to manage ads in the player code


Each ad has an id parameter.

It allows you to manage ads in the code without having to update the player each time to change the ad queue (you only need to update if you have connected a new ad).

In the builder you need to enable the VAST plugin and the desired formats. In the code you need specify the identifiers with the parameters preroll, pauseroll, postroll or midroll.

var player = new Playerjs({id:"player", file:"//site.com/video.mp4", preroll:"id:XXX or id:YYY"});

In this example, two ads with the identifiers XXX and YYY are connected through the or operator (the second advertisement will run only if the first is inactive). There is also the operator and (all ads will be requested). Operators can be combined:

preroll:"id:XXX or id:YYY and id:AAA or id:BBB"

In this example a maximum of two ads (one of each pair) will work.

Midrolls

Midrolls are connected in the code with the launch time (do not forget to include this format in the builder).),

midroll:[{time:"5",vast:"id:XXX or id:YYY"},{time:"50%",vast:"id:ZZZ"}]

time in seconds or percentages.

Restrictions by platforms

You can selectively prevent ads from running on platforms by specifying a restriction in square brackets after the id.

pauseroll:"id:XXX[no_desktop] and id:YYY[no_mobile]"

[no_desktop] — ads will not work on desktop computers

[no_mobile] — ads will not work on mobile

[no_mobiletv] — ads will not work on mobile and TVs

[no_tv] — ads will not work on TVs

Disabling ads

To selectively disable advertising, which is added in the designer there are parameters preroll_deny, pauseroll_deny, postroll_deny, midroll_deny depending on the type of advertising.

preroll_deny:"id1,id2,id3"

You can also disable all ads with the vast option.

var player = new Playerjs({id:"player", file:"//site.com/video.mp4", vast:0});

You can also use startvast command in the JS API to launch an ad network by id.




2020 © PlayerJS

Login

Restore password
Sign up
Log in

Sign up free

Sign up
By signing up, you agree to Terms of Service
Login if you have an account

Enterprise

Your name
Website
Email
Phone
Description
Order player

Restore password

Restore
Forgot email? Contact us