videojs-preroll icon indicating copy to clipboard operation
videojs-preroll copied to clipboard

Initialize videojs-contrib-ads sooner to avoid redispatch issues

Open incompl opened this issue 8 years ago • 1 comments

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"
});

More information in the videojs-contrib-ads readme

incompl avatar Dec 06 '17 16:12 incompl

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.

incompl avatar Dec 06 '17 16:12 incompl