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. If advertising is also enabled in the editor, then the inventory from the code will be added to the beginning of the advertising chain. You can exclude this with the prerollnew:1 parameter (in this case, the data from the editor will not be used).

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", minduration:100}]

time – the start point in seconds or percentages.

minduration – the minimum duration of the content in seconds (advertising will work if the content is longer than the specified value). This option is supported since version 16.1

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

[remove] — ad link will be removed from the waterfall after the first request

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.


17.1.62022 © PlayerJS

Sign up free

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

Restore password

Restore
Forgot email? Contact us