Skip to content

Commit

Permalink
fix(Ads): Don't load useless segments when using playoutLimit on inte…
Browse files Browse the repository at this point in the history
…rstitial ads (#7469)
  • Loading branch information
avelad authored Oct 23, 2024
1 parent 25e7620 commit 7d8510b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/ads/interstitial_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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)));
Expand Down

0 comments on commit 7d8510b

Please sign in to comment.