Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent content from being restarted after Postroll ads #4979

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/ads/client_side_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ shaka.ads.ClientSideAdManager = class {
/** @private {shaka.util.EventManager} */
this.eventManager_ = new shaka.util.EventManager();

/** @private {boolean} */
this.contentCompletedCalled_ = false;

google.ima.settings.setLocale(locale);

const adDisplayContainer = new google.ima.AdDisplayContainer(
Expand Down Expand Up @@ -80,6 +83,7 @@ shaka.ads.ClientSideAdManager = class {

// Notify the SDK when the video has ended, so it can play post-roll ads.
this.video_.onended = () => {
this.contentCompletedCalled_ = true;
this.adsLoader_.contentComplete();
};
}
Expand Down Expand Up @@ -154,6 +158,7 @@ shaka.ads.ClientSideAdManager = class {
(new Map()).set('loadTime', loadTime)));

this.imaAdsManager_ = e.getAdsManager(this.video_);
this.contentCompletedCalled_ = false;

this.onEvent_(new shaka.util.FakeEvent(
shaka.ads.AdManager.IMA_AD_MANAGER_LOADED,
Expand Down Expand Up @@ -452,7 +457,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.contentCompletedCalled_) {
gingman marked this conversation as resolved.
Show resolved Hide resolved
this.video_.play();
}
}
}
};