Skip to content

Commit

Permalink
fix(ads): Fix ads starting muted behavior (shaka-project#5153)
Browse files Browse the repository at this point in the history
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 shaka-project#5125
  • Loading branch information
theodab committed Apr 14, 2023
1 parent d475a73 commit 211624f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ads/client_side_ad_manager.js
Expand Up @@ -457,7 +457,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);
}
}
}

Expand Down

0 comments on commit 211624f

Please sign in to comment.