Skip to content

Commit

Permalink
fix(Ads): Limit interstitial duration to actual duration if available
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Oct 23, 2024
1 parent fac9d84 commit c4431ad
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/ads/interstitial_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,25 @@ shaka.ads.InterstitialAdManager = class {
});
try {
this.updatePlayerConfig_();
// playRangeEnd in src= causes the ended event not to be fired when that
// position is reached.
const loadMode = this.basePlayer_.getLoadMode();
if (loadMode == shaka.Player.LoadMode.MEDIA_SOURCE &&
interstitial.startTime && interstitial.endTime &&
interstitial.endTime != Infinity &&
interstitial.startTime != interstitial.endTime) {
const duration = interstitial.endTime - interstitial.startTime;
if (duration > 0) {
this.player_.configure('playRangeEnd', duration);
}
}
if (interstitial.playoutLimit) {
playoutLimitTimer = new shaka.util.Timer(() => {
ad.skip();
}).tickAfter(interstitial.playoutLimit);
this.player_.configure('playRangeEnd', interstitial.playoutLimit);
if (loadMode == shaka.Player.LoadMode.MEDIA_SOURCE) {
this.player_.configure('playRangeEnd', interstitial.playoutLimit);
}
}
await this.player_.attach(this.video_);
if (this.preloadManagerInterstitials_.has(interstitial)) {
Expand Down

0 comments on commit c4431ad

Please sign in to comment.