videojs / videojs-contrib-ads

A Tool for Building Video.js Ad Plugins
http://videojs.github.io/videojs-contrib-ads/
Other
381 stars 257 forks source link

Doesn't switch to next video in playlist after postroll #497

Open polucorus opened 5 years ago

polucorus commented 5 years ago

I've got a playlist with auto advancing on and it just pauses after the postroll instead of switching to the next video. Based on my debugging, without postroll it switches to the AdsDone state and with it, it doesn't.

When endLinearAdMode() is called, the transition is in the callback but that callback is never executed because the end() method calls restorePlayerSnapshot() and in the end of it there's a condition:

if (player.ads.videoElementRecycled()) {
   // ...
   player.on('resumeended', callback)
} else {
   // ...
   callback();
}

It goes into the first branch but resumeended is never triggered because isContentResuming() returns false. How to make it go down the playlist?

To be clear, with only preroll it works fine. I've implemented both preroll and postroll based on the official guide. I don't use googleads-ima, just contrib-ads 6.6.3 and videojs-playlist 4.3.1.

polucorus commented 5 years ago

Further investigation has shown that isContentResuming() returns false in that case because apparently the ended event is triggered before endLinearAdMode() where the contentResuming property is set to true. Why is that?

polucorus commented 5 years ago

Turning on autoplay() helped on Chrome, even though it wasn't required without the preroll. On Firefox it doesn't trigger transition to AdsDone so the player repeats the same video again.

Also, the contrib-ads doesn't properly restore autoadvance() state of the playlist — I have to set it on every adended.