Skip to content

Commit

Permalink
fix(ads): Fix ads starting muted behavior (#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 #5125
  • Loading branch information
theodab authored and joeyparrish committed Apr 26, 2023
1 parent 29b7a30 commit cbfaa70
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ads/client_side_ad_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,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 cbfaa70

Please sign in to comment.