diff --git a/lib/ads/interstitial_ad_manager.js b/lib/ads/interstitial_ad_manager.js index 91c1f3707f..1fba90c5a8 100644 --- a/lib/ads/interstitial_ad_manager.js +++ b/lib/ads/interstitial_ad_manager.js @@ -39,6 +39,9 @@ shaka.ads.InterstitialAdManager = class { * @param {function(!shaka.util.FakeEvent)} onEvent */ constructor(adContainer, basePlayer, baseVideo, onEvent) { + /** @private {?shaka.extern.AdsConfiguration} */ + this.config_ = null; + /** @private {HTMLElement} */ this.adContainer_ = adContainer; @@ -197,11 +200,26 @@ shaka.ads.InterstitialAdManager = class { * @param {shaka.extern.AdsConfiguration} config */ configure(config) { - if (!this.adContainer_ || - this.usingBaseVideo_ != config.supportsMultipleMediaElements) { + this.config_ = config; + } + + /** + * @private + */ + determineIfUsingBaseVideo_() { + if (!this.adContainer_ || !this.config_ || this.playingAd_) { + return; + } + let supportsMultipleMediaElements = + this.config_.supportsMultipleMediaElements; + const video = /** @type {HTMLVideoElement} */(this.baseVideo_); + if (video.webkitSupportsFullscreen && video.webkitDisplayingFullscreen) { + supportsMultipleMediaElements = false; + } + if (this.usingBaseVideo_ != supportsMultipleMediaElements) { return; } - this.usingBaseVideo_ = !config.supportsMultipleMediaElements; + this.usingBaseVideo_ = !supportsMultipleMediaElements; if (this.usingBaseVideo_) { this.video_ = this.baseVideo_; if (this.adVideo_) { @@ -491,6 +509,7 @@ shaka.ads.InterstitialAdManager = class { */ async setupAd_(interstitial, sequenceLength, adPosition, initialTime, oncePlayed = 0) { + this.determineIfUsingBaseVideo_(); goog.asserts.assert(this.video_, 'Must have video'); this.lastPlayedAd_ = interstitial; @@ -618,6 +637,7 @@ shaka.ads.InterstitialAdManager = class { this.baseVideo_.play(); } } + this.determineIfUsingBaseVideo_(); } }; const error = async (e) => {