From d55479ccc5c66c4bafc942f10ea2a0cea0f9f1ad Mon Sep 17 00:00:00 2001 From: theodab Date: Fri, 14 Apr 2023 15:17:20 -0700 Subject: [PATCH] fix(ads): Fix ads starting muted behavior (#5153) Previously, we would set the starting volume of an ad to 0 if the main video is muted. This had the problem that, because of how our custom mute/unmute functionality on ads worked, that would lead to the "unmute" button setting the ad to the "last volume" of 0. This changes the ads manager to, instead, set the volume of the ad to the volume of the video, and then call the mute function if the ad is muted. That way, the ad will remember the previous volume of the video, and will be able to unmute properly. Closes #5125 --- lib/ads/client_side_ad_manager.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ads/client_side_ad_manager.js b/lib/ads/client_side_ad_manager.js index 2ae0ac97e8..fbaaf70efb 100644 --- a/lib/ads/client_side_ad_manager.js +++ b/lib/ads/client_side_ad_manager.js @@ -440,7 +440,10 @@ shaka.ads.ClientSideAdManager = class { if (this.ad_.isLinear()) { this.adContainer_.setAttribute('ad-active', 'true'); this.video_.pause(); - this.ad_.setVolume(this.video_.muted ? 0 : this.video_.volume); + this.ad_.setVolume(this.video_.volume); + if (this.video_.muted) { + this.ad_.setMuted(true); + } } }