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 committed Jan 9, 2024
1 parent 8476631 commit a8bbbce
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
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
Expand Up @@ -532,9 +532,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 a8bbbce

Please sign in to comment.