One of the best features of Video.js is the community of plugins and customizations that has built up around it. Ad support is an important part of that ecosystem, but not all plugin authors write with advertisements in mind. Brightcove is making some big changes in videojs-contrib-ads to make advertisements more compatible with the rest of the Video.js universe. In version 2.0 of the plugin, the plugin re-dispatches events with different prefixes depending on whether an ad is playing or not. When an ad is playing, events are prefixed with ad and when content is resuming after an ad break, events are prefixed with content. For instance, a
pause event during an ad would become an
adpause event. This means from the perspective of a (non-ad) plugin author, Video.js will behave just the same whether ads are playing or not. And if someone wants to write a plugin that is ad-aware, those original events are still available for them to hook into.
If you've written your own ad integration on top of videojs-contrib-ads, there's a couple things you should do to prepare for the upgrade:
- Apply the appropriate prefix to your event handlers. If you were listening for
timeupdateevents during ad playback, you should now be listening for
adtimeupdate. Video events that occur during content playback are unaffected.
- Listen for
contentendedto trigger postrolls instead of
ended. When the content is playing, the
endedevent gets captured and re-dispatched as
contentendedso that other plugins don't see multiple
endedevents for the same video. After the content and postrolls have finished, contrib-ads will fire an
- Advise your users to include and initialize your plugin before they fire up other plugins. The contrib-ads plugin will take care of re-dispatching events, but it can't hide them for plugins that are registered earlier in the listener chain.
- The extended support for postrolls added a new
postrollTimeoutoption, similar to prerolls. If you do not wish to play a postroll for a video, you can fire
adtimeoutto proceed to the next video immediately.