From 6dcd1443f5ce61fa2119940cc507eccf67a51fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Wed, 23 Oct 2024 16:29:26 +0200 Subject: [PATCH 1/2] fix(Ads): Disable interstitials when using AirPlay --- lib/ads/interstitial_ad_manager.js | 2 +- lib/player.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/ads/interstitial_ad_manager.js b/lib/ads/interstitial_ad_manager.js index bd47755a18..9f6f40bde8 100644 --- a/lib/ads/interstitial_ad_manager.js +++ b/lib/ads/interstitial_ad_manager.js @@ -93,7 +93,7 @@ shaka.ads.InterstitialAdManager = class { this.lastPlayedAd_ = null; this.eventManager_.listen(this.baseVideo_, 'timeupdate', () => { - if (this.playingAd_) { + if (this.playingAd_ || this.basePlayer_.isRemotePlayback()) { return; } const needPreRoll = this.lastTime_ == null || this.lastTime_ == 0; diff --git a/lib/player.js b/lib/player.js index 670b9be404..ebb4259428 100644 --- a/lib/player.js +++ b/lib/player.js @@ -8092,6 +8092,19 @@ shaka.Player = class extends shaka.util.FakeEventTarget { shaka.util.Error.Category.PLAYER, shaka.util.Error.Code.LOAD_INTERRUPTED); } + + /** + * Indicate if we are using remote playback. + * + * @return {boolean} + * @export + */ + isRemotePlayback() { + if (!this.video_ || !this.video_.remote) { + return false; + } + return this.video_.remote.state != 'disconnected'; + } }; /** From 6071629e45898e9538a435a433283655bbb7c15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=CC=81lvaro=20Velad=20Galva=CC=81n?= Date: Wed, 23 Oct 2024 17:10:53 +0200 Subject: [PATCH 2/2] Fix tests --- test/cast/cast_utils_unit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cast/cast_utils_unit.js b/test/cast/cast_utils_unit.js index b3e0bc74b3..fa334fb802 100644 --- a/test/cast/cast_utils_unit.js +++ b/test/cast/cast_utils_unit.js @@ -35,6 +35,7 @@ describe('CastUtils', () => { 'getNonDefaultConfiguration', 'addFont', 'getFetchedPlaybackInfo', + 'isRemotePlayback', // Test helper methods (not @export'd) 'createDrmEngine',