videojs-contrib-ads icon indicating copy to clipboard operation
videojs-contrib-ads copied to clipboard

Improve code that calls play for ads

Open incompl opened this issue 7 years ago • 3 comments

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.

incompl avatar Apr 30 '18 19:04 incompl

I have a question about this. There is not any clue about triggering these events..nowhere. Are you sure that these events really occur?

mysuf avatar May 03 '18 11:05 mysuf

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.

incompl avatar May 03 '18 15:05 incompl

Ah. So this is how it works! Thanks.

mysuf avatar May 03 '18 15:05 mysuf