Video.js recently added new functionality for autoplay that triggers autoplay-success or autoplay-failure events depending on the result of the autoplay attempt. However, that functionality relies on the initial play promise being resolved/rejected naturally, so it is not compatible with the contrib-ads callPlay() middleware which terminates the first play request.
This PR adds an option to bypass that play termination if the player intends to autoplay. It does this by conditionally setting _shouldBlockPlay to false in the BeforePreroll state if the option is true and player.autoplay() is truthy.
Description
Video.js recently added new functionality for autoplay that triggers
autoplay-success
orautoplay-failure
events depending on the result of the autoplay attempt. However, that functionality relies on the initial play promise being resolved/rejected naturally, so it is not compatible with the contrib-adscallPlay()
middleware which terminates the first play request.This PR adds an option to bypass that play termination if the player intends to autoplay. It does this by conditionally setting
_shouldBlockPlay
tofalse
in theBeforePreroll
state if the option istrue
andplayer.autoplay()
is truthy.