Skip to content

Commit

Permalink
fix: Prevent content from being restarted after Postroll ads (shaka-p…
Browse files Browse the repository at this point in the history
…roject#4979)

After watching post roll ads, `this.video_.play()` was called on a completed content in the `onAdComplete` event.
The content would then restart from the beginning.

We now flag that the content is completed before we call `this.adsLoader_.contentComplete()`.
On the callback, we prevent the video element from replaying if this flag is set.

This fix is based on the Advanced Sample on the [googleads-ima-html5 repo](https://github.com/googleads/googleads-ima-html5/blob/main/advanced/ads.js#L128)

Closes shaka-project#4445
  • Loading branch information
gingman committed Feb 9, 2023
1 parent 9d2c325 commit 64e94f1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ads/client_side_ad_manager.js
Expand Up @@ -452,7 +452,9 @@ shaka.ads.ClientSideAdManager = class {
(new Map()).set('originalEvent', e)));
if (this.ad_ && this.ad_.isLinear()) {
this.adContainer_.removeAttribute('ad-active');
this.video_.play();
if (!this.video_.ended) {
this.video_.play();
}
}
}
};

0 comments on commit 64e94f1

Please sign in to comment.