Skip to content

Commit

Permalink
fix(Ads): Fix VMAP won't play in muted autoplay (#6046)
Browse files Browse the repository at this point in the history
Fixes #6020
Fixes #6037
  • Loading branch information
avelad authored and joeyparrish committed Feb 17, 2024
1 parent 468425a commit 5201950
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/ads/client_side_ad.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ shaka.ads.ClientSideAd = class {
}
}

/**
* It's required for a muted ad to start when autoplaying.
*
* @param {number} videoVolume
*/
setInitialMuted(videoVolume) {
this.volume_ = videoVolume;
this.manager_.setVolume(0);
}

/**
* @override
Expand Down
5 changes: 3 additions & 2 deletions lib/ads/client_side_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,10 @@ shaka.ads.ClientSideAdManager = class {
if (this.ad_.isLinear()) {
this.adContainer_.setAttribute('ad-active', 'true');
this.video_.pause();
this.ad_.setVolume(this.video_.volume);
if (this.video_.muted) {
this.ad_.setMuted(true);
this.ad_.setInitialMuted(this.video_.volume);
} else {
this.ad_.setVolume(this.video_.volume);
}
}
}
Expand Down

0 comments on commit 5201950

Please sign in to comment.