MailOnline / videojs-vast-vpaid

video.js vast plugin
MIT License
296 stars 232 forks source link

Ad Plays but no events are fired #269

Open ramynasr opened 7 years ago

ramynasr commented 7 years ago

This issue has been reported multiple times under different names:

After some debugging, it seems that the main issue is that all these events depend on the durationchange event being fired. The problem is that this event won't fire if the original video content has the same length as the Ad being played and the VASTIntegrator will never know that the AdUnit is actually playing.

You can see that here:

VASTIntegrator.prototype._playSelectedAd = function playSelectedAd(source, response, callback) {
  var player = this.player;
  player.preload("auto"); //without preload=auto the durationchange event is never fired
  player.src(source);

  logger.debug ("<VASTIntegrator._playSelectedAd> waiting for durationchange to play the ad...");

  playerUtils.once(player, ['durationchange', 'error', 'vast.adsCancel'], function (evt) {
    if (evt.type === 'durationchange') {
      logger.debug ("<VASTIntegrator._playSelectedAd> got durationchange; calling playAd()");
      playAd();
    } else if(evt.type === 'error') {
      callback(new VASTError("on VASTIntegrator, Player is unable to play the Ad", 400), response);
    }
    //NOTE: If the ads get canceled we do nothing/
  });

To reproduce the issue, try setting the src of the actual video element to a 15 seconds video then test the plugin with an Ad that is also 15 seconds long.