Skip to content

Commit

Permalink
feat(Ads): Improve preload timing on interstitials (#6792)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jun 12, 2024
1 parent 65b0b8d commit 4638775
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/ads/interstitial_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,19 @@ shaka.ads.InterstitialAdManager = class {
}
this.interstitialIds_.add(interstitialId);
this.interstitials_.add(interstitialAd);
if (this.lastTime_ != null) {
let shouldPreload = false;
if (interstitialAd.startTime == 0 && !interstitialAd.canJump) {
shouldPreload = true;
} else if (this.lastTime_ != null) {
const difference = interstitial.startTime - this.lastTime_;
if (difference > 0 && difference <= 10) {
if (!this.preloadManagerInterstitials_.has(interstitialAd)) {
this.preloadManagerInterstitials_.set(
interstitialAd, this.player_.preload(interstitialAd.uri));
}
shouldPreload = true;
}
}
if (shouldPreload) {
if (!this.preloadManagerInterstitials_.has(interstitialAd)) {
this.preloadManagerInterstitials_.set(
interstitialAd, this.player_.preload(interstitialAd.uri));
}
}
}
Expand Down

0 comments on commit 4638775

Please sign in to comment.