3

I'm trying to use pre-roll ads on youtube videos on the website I'm working on using the latest (4.11.4) version of video.js. Youtube vidoes are played thanks to the videojs-youtube plugin I found on github https://github.com/eXon/videojs-youtube , while for the ADs part I'm using this videojs-vast-plugin https://github.com/theonion/videojs-vast-plugin that reads a VAST 2.0 formatted xml I serve from the one provided by Revive Ad-Server (v. 3.0) and plays and mp4 video.

This is the code I wrote:

//= require video.dev
//= require youtube
//= require vast-client
//= require video.ads
//= require videojs.vast

<video id="video" class="video-js vjs-default-skin" controls preload="auto" width="610" height="343">
</video>

<script>
$(function(){
  videojs('video', {plugins: {
     ads: {},
     vast: {
        url: '{{url("ad-url")}}',
        skip: 2
     }
  },
  src: "http://www.youtube.com/watch?v={{youtubeCode}}",
  techOrder: ["youtube", 'html5', 'flash']
  })
});
</script>

This code works partially: I can succesfully show the YouTube video's poster image, play the custom video AD (with the "Skip in 2 seconds" alert, as per config), skip the video if I want, but everytime the AD ends (or it's skipped) I get this errors:

Uncaught TypeError: Cannot read property 'vdata1423499421192' of null
Uncaught TypeError: Cannot read property 'handleSource' of null

By doing some research I think the problem might be the second player not being "re-inizialized" after the AD stops, but I can't figure out where to act in order to prevent this. I found some answers where they suggested to add a timeout before firing the dispose() method, but it's scattered all over the plugins and I can't understand which one is actually acting. When I change the order of the elements in "techOrder", specifically when I switch place for flash and html5 the "vdata1423499421192" error disappears, but still the video won't play.

Moreover, if I play two regular mp4 videos (mp4 video with mp4 ads) the combination video.js + vast-plugin works ok.

Edit: I found this bug report on Github dealing with a similar problem, but no luck with the solutions provided

Damien Pirsy
  • 25,319
  • 8
  • 70
  • 77

0 Answers0