videojs / videojs-contrib-ads

A Tool for Building Video.js Ad Plugins
http://videojs.github.io/videojs-contrib-ads/
Other
384 stars 257 forks source link

how to change content source correctly #346

Closed Pong420 closed 6 years ago

Pong420 commented 6 years ago

Hi,

i am working on resolution change by changing video source, but seems conflict with this plugin, player is stalled around 5 second after source change

screen shot 2018-03-08 at 11 46 38 am

incompl commented 6 years ago

The main thing I suggest is to not do source changes during ad mode. Is player.ads.isInAdMode() true when you are changing sources? If you want to change sources during an ad, I suggest you first end the ad.

Pong420 commented 6 years ago

player.ads.isInAdMode() is false

screen shot 2018-03-09 at 11 04 36 am

incompl commented 6 years ago

Hmm this all seems OK. The error you're seeing in the console is a normal result of how cancelContentPlay works (we're changing how that works in this PR which will make that error go away).

I'm curious to know more about the state of the player when it is stalled. Is it paused? What is displayed visually?

If you could share an example that demonstrates the issue that would help a lot too.

Pong420 commented 6 years ago

Sorry, i am not state clearly.

Action Change another video source and receive a loadedmetadata event

Expectation The player continue to play

Result The player continue to play after 5 second

So my problem is how to remove the 5 second. If set timeout to 0 work fine, but i worry that this may cause other problems

Here is the example, after video ad ended, click on the button to change video https://ads-issue-346.herokuapp.com/

incompl commented 6 years ago

Ah I see, this is because the plugin does preroll checks again after you change sources. You can either play a preroll the same way you do for the initial source, or you can trigger a nopreroll event on the player like this: player.trigger('nopreroll');

Pong420 commented 6 years ago

thanks so much~