theonion / videojs-vast-plugin

A VideoJS plugin for VAST
theonion.github.io/videojs-vast-plugin/
MIT License
263 stars 174 forks source link

Replay video and VAST #62

Open HackingAway opened 9 years ago

HackingAway commented 9 years ago

I have a pre-roll video playing via VAST. Works well (Thank you)

After the video plays, I want to automatically reload the player and play the next video. I have tried different methods, but the pre-roll video doesn't play.

The kinda confusing part is that there is an videojs .ended() event fires when the VAST pre-roll video ends. (I am not sure that it should from an overall perspective)

I am ok with reloading the player and getting another pre-roll video but for some reason I can't get it to try to reload another video when the ended event fires. Any ideas?

 vid2.ready(function(){
          this.on("ended", function(){ 
                    console.log("ended");
                    var vid2 = videojs("vid2");
                    vid2.dispose();
                    //put it back into the same div
                    videojs("vid2", {"preload":"auto","width":1920,"height":1080}, function(){
                    // Player (this) is initialized and ready.
                    this.src("http://video-js.zencoder.com/oceans-clip.mp4");
                     this.ads();
                        this.vast({
                          skip: -1,
                      url: 'https://vastserver/example'
                            });
                    });
                    this.play();

          });
trajkovvlatko commented 9 years ago

Hello

Just wanted to ask if you had any progress with this problem. I'm stuck with the same thing and can't do it properly (reload the video with a different source and different pre-rolls, from a different vast file)

Thanks!

HackingAway commented 9 years ago

Yes, I did eventually get it to work but not in a way I would recommend. I queried the ad server for the VAST ad, set the video source to that ad, and then when it was done, set the source to the next video. The end event wasn't firing reliably in firefox so on each video grab, I had to figure out what the length of the video was in seconds and set a timer to get the next video when that timer expired. I was replaying video after video and the player would eventually crash so I moved on for now. I will have to visit this again in the future.

On Fri, Jun 12, 2015 at 11:02 AM, Vlatko Trajkov notifications@github.com wrote:

Hello

Just wanted to ask if you had any progress with this problem. I'm stuck with the same thing and can't do it properly (reload the video with a different source and different pre-rolls, from a different vast file)

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/theonion/videojs-vast-plugin/issues/62#issuecomment-111519581 .

trajkovvlatko commented 9 years ago

Thanks for the info. I'm trying to avoid this way, because of the additional fetching and parsing of the vast file, so started patching the ads and vast plugins for videojs. Will let you know if there's any success. Thanks again.

trajkovvlatko commented 8 years ago

A bit late, but here's what worked for me:

In videojs.vast.js, inside

Vast = function (player, settings) {

add this function:

reload: function(url){
    settings.url = url;
},

and when you need to trigger an ad while the video is playing, change the url with:

player.vast.reload(yourNewVastLink);
player.trigger("contentupdate");

For some browsers, you must save the last position before triggering the contentupdate and seek to that position when the ad ended. Hope it helps.