From 5e522d3fca1a3f35379a31f2e132183497f7cd73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Wed, 23 Oct 2024 08:12:26 +0200 Subject: [PATCH] fix(Ads): Don't load useless segments when using playoutLimit on interstitial ads (#7469) --- lib/ads/interstitial_ad_manager.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ads/interstitial_ad_manager.js b/lib/ads/interstitial_ad_manager.js index 58880bba25..bd47755a18 100644 --- a/lib/ads/interstitial_ad_manager.js +++ b/lib/ads/interstitial_ad_manager.js @@ -674,12 +674,13 @@ shaka.ads.InterstitialAdManager = class { } }); try { + this.updatePlayerConfig_(); if (interstitial.playoutLimit) { playoutLimitTimer = new shaka.util.Timer(() => { ad.skip(); }).tickAfter(interstitial.playoutLimit); + this.player_.configure('playRangeEnd', interstitial.playoutLimit); } - this.updatePlayerConfig_(); await this.player_.attach(this.video_); if (this.preloadManagerInterstitials_.has(interstitial)) { const preloadManager = @@ -693,6 +694,14 @@ shaka.ads.InterstitialAdManager = class { } else { await this.player_.load(interstitial.uri); } + if (interstitial.playoutLimit) { + if (playoutLimitTimer) { + playoutLimitTimer.stop(); + } + playoutLimitTimer = new shaka.util.Timer(() => { + ad.skip(); + }).tickAfter(interstitial.playoutLimit); + } const loadTime = (Date.now() - startTime) / 1000; this.onEvent_(new shaka.util.FakeEvent(shaka.ads.Utils.ADS_LOADED, (new Map()).set('loadTime', loadTime)));