videojs-contrib-ads
videojs-contrib-ads copied to clipboard
Improve code that calls play for ads
Right now it does this:
player.on(['addurationchange', 'adcanplay'], function(e) {
It should only run this code once, right now it can run once for each event, then more if the events are duplicated. Maybe it can be a one handler on startLinearAdMode.
I have a question about this. There is not any clue about triggering these events..nowhere. Are you sure that these events really occur?
If the content video element is used for ad playback, the normal media events will be redispatched with the ad prefix. That also is when we need to call play in this code. Relying on media events can be fussy because browser implementations differ, but durationchange and canplay haven't been an issue for us.
Ah. So this is how it works! Thanks.