videojs-preroll
videojs-preroll copied to clipboard
Initialize videojs-contrib-ads sooner to avoid redispatch issues
I'm referring to this part:
videojs('example_video_1', {}, function(){
var player = this;
player.preroll({
src:"advertisement.mp4"
});
});
This initializes the preroll plugin on player ready, which in turn initializes videojs-contrib-ads.
We have had a lot of bugs where people initialized this way because contrib-ads' redispatch feature is not initialized until player ready, which means a lot of events don't get redispatched up until when then. We've seen people rely on those events for analytics, for example.
Other work may need to be done to support this, but you'll want config to look something like this:
var player = videojs('example_video_1');
player.preroll({
src:"advertisement.mp4"
});
Additionally, videojs-contrib-ads 5.x logs a warning and fails to play ads if it is initialized late, so this is needed for 5.x support.