MailOnline / videojs-vast-vpaid

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

help with multiple vasts sources implementation #167

Open michalk-k opened 8 years ago

michalk-k commented 8 years ago

Hi guys I cannot find any dedicated forum for what I want to ask.

Let's say system is able to provide list of VAST providers (as xml file). Point is to try to load and play each VAST and in case of failure, try next VAST source. There may be a few reasons why accessing VAST may fail: capping on provider side, error on provider side, error accessing video stream. Most often it's capping which results either in empty VAST file or xml feed without data (root element only).

Requested scenario:

  1. provider list should be loaded on a video first play
  2. player tries to play first preroll
  3. in case of error, it tries to open next vast url
  4. if no prerolls left, it starts to play video.

I'm fiddling with the plugin for a few days and cannot get satisfying result. I don't know how to effectively force it to try subsequent vast providers. Looks like override playPrerollAd method is the only way. Maybe you have better idea

Would you like to help me with this?

with regards

Fetz commented 8 years ago

The only thing implemented in terms of fallback is the waterfall or VAST Wrapper Ads for Ad Server Redirects.

The code implemented I think is around here: https://github.com/MailOnline/videojs-vast-vpaid/blob/master/src/scripts/ads/vast/VASTClient.js#L67

You can check more info here: https://support.jwplayer.com/customer/portal/articles/1665150-ad-tag-waterfalling https://support.google.com/dfp_premium/answer/3007370?hl=en http://www.iab.com/wp-content/uploads/2015/06/VASTv3_0.pdf

michalk-k commented 8 years ago

Thank you. I didn't know it's called waterfalling. Yes, it is. Recently I managed how to make it work. Don't know if is it proper at the end of day, but it works so far. I rewrite playPrerollAd method a bit to call itself recurrently. pp.NextVast is my object's method which prepares next vast URL, accessible in getAdsUrl method.

function playPrerollAd(callback) {
        async.waterfall([
            getVastResponse,
            playAd
        ], function (error, response) {
            if (error) {
                if (pp.GetNextVast() == null) {
                } else {
                    playPrerollAd(callback);
                }
            } else {
                player.trigger('vast.adEnd');
            }
        });
    }

Right now two things left. To implement it nicely, by overriding method instead of changing original code. But I didn't make it so far. Looks like I cannot override local method. But I'm JS beginner rather so maybe there is a way. Second thing is to load my data (list of VAST urls) when original video is going to be played but before VAST plugin starts its work. Still didn't managed how to do that. But loading it before initialization of videojs is considered as temp workaround

with regards

592da commented 8 years ago

Someone managed to get this work ? Thanks

DoomTay commented 6 years ago

A bit late, but MailOnline/videojs-vast-vpaid#256 seems to add multiple ad server support. I haven't had a chance to try it out myself though