Skip to content

Commit

Permalink
fix(Ads): Fix duplicate Ads when playing interstitials through native…
Browse files Browse the repository at this point in the history
… HLS player (#7527)
  • Loading branch information
avelad authored Oct 31, 2024
1 parent fb1ce42 commit 075713f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/ads/interstitial_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ shaka.ads.InterstitialAdManager = class {
}
let cuepointsChanged = false;
for (const interstitial of interstitials) {
const interstitialId = JSON.stringify(interstitial);
const interstitialId = interstitial.id || JSON.stringify(interstitial);
if (this.interstitialIds_.has(interstitialId)) {
continue;
}
Expand Down Expand Up @@ -777,6 +777,16 @@ shaka.ads.InterstitialAdManager = class {
if (hlsInterstitialId) {
id = /** @type {string} */(hlsInterstitialId.data);
}
const startTime = id == null ?
Math.floor(hlsInterstitial.startTime * 10) / 10:
hlsInterstitial.startTime;
let endTime = hlsInterstitial.endTime;
if (hlsInterstitial.endTime && hlsInterstitial.endTime != Infinity &&
typeof(hlsInterstitial.endTime) == 'number') {
endTime = id == null ?
Math.floor(hlsInterstitial.endTime * 10) / 10:
hlsInterstitial.endTime;
}
const restrict = hlsInterstitial.values.find((v) => v.key == 'X-RESTRICT');
let isSkippable = true;
let canJump = true;
Expand Down Expand Up @@ -851,8 +861,8 @@ shaka.ads.InterstitialAdManager = class {
}
interstitialsAd.push({
id,
startTime: hlsInterstitial.startTime,
endTime: hlsInterstitial.endTime,
startTime,
endTime,
uri,
isSkippable,
skipOffset,
Expand Down Expand Up @@ -901,8 +911,8 @@ shaka.ads.InterstitialAdManager = class {
if (asset['URI']) {
interstitialsAd.push({
id,
startTime: hlsInterstitial.startTime,
endTime: hlsInterstitial.endTime,
startTime,
endTime,
uri: asset['URI'],
isSkippable,
skipOffset,
Expand Down

0 comments on commit 075713f

Please sign in to comment.