videojs / videojs-contrib-ads

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

Fix: Player does not trigger 'play' and 'pause' events first time after AdBlocker block Ads #513

Closed marcodeltorob closed 4 years ago

marcodeltorob commented 4 years ago

Problem Description

When Preroll is blocked due to AdBlocker the plugin will trigger an adtimeout event then content will play without any event trigger like play or contentplay or transition to ContentPlayback state. So, the first event triggered if we call player.play() or player.pause() will be prefixed with content (contentpause or contentplay) and plugin will transition from Preroll -> ContentPlayback because we are in Preroll stuck.

Solution Proposal

When we have and adtimeout in Preroll state transition to ContentPlayback

marcodeltorob commented 4 years ago

What resumeAfterNoPreroll does is to set contentResuming to true and unlock playback with player.ads._shouldBlockPlay = true also remove the timeout function and the CSS (vjs-ad-loading & vjs-ad-content-resuming).

In a normal scenario, the plugin will transition from Preroll -> ContentPlayback after the Ad brake but here the plugin is getting stuck in Preroll state so that is why inside the onAdTimeout() I'm proposing a transition to ContentPlayback in case of the adtimeout is triggered since due to the AdBlocker the plugin does not fire more events and is not transitioning until the first manual player.play() and that is why the player is sending a contentplay instead of on play event.

gkatsev commented 4 years ago

I'm a bit worried that this will change the behavior of adtimeout in the case adblockers aren't available. Like if the ad response is slow or the response contains no ads.

misteroneill commented 4 years ago

As discussed offline, we think this carries some risk of creating other undesirable behaviors and will close for now. If this issue comes back up, we can revisit!