mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-18 16:36:56 +03:00
fix(Ads): Limit interstitial duration to actual duration if available (#7480)
Currently, if the interstitial lasts 30 and we have a stream that lasts 31 seconds, we would go back to live after the interstitial, but with 1 extra second of latency. This PR solves this by limiting the play range to 30.
This commit is contained in:
committed by
GitHub
parent
4e6e37c0ce
commit
ad9f2ac039
@@ -680,11 +680,26 @@ shaka.ads.InterstitialAdManager = class {
|
||||
});
|
||||
try {
|
||||
this.updatePlayerConfig_();
|
||||
// playRangeEnd in src= causes the ended event not to be fired when that
|
||||
// position is reached. So we don't use it because we would never go back
|
||||
// to the main stream.
|
||||
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)) {
|
||||
|
||||
Reference in New Issue
Block a user