Fixed a bug where the mute icon could desync from the actual mute state.

Due to source.muted not being set in the volume slider listener, it was
possible to desync the mute icon state by lowering the volume to zero and then
clicking the mute button.
This commit is contained in:
Erik Thuning 2025-01-30 14:29:31 +01:00
parent 633d9436f4
commit db68e2b86b

@ -1239,6 +1239,11 @@ input[type="range"]::-ms-track {
source.muted = true;
localStorage.setItem(muteStore, true);
} else {
if (source.volume === 0) {
// If unmuting after having manually moved the
// volume slider to 0, set a sane default volume.
source.volume = 0.5;
}
this._volumeSlider.value = source.volume;
source.muted = false;
localStorage.removeItem(muteStore);
@ -1256,11 +1261,13 @@ input[type="range"]::-ms-track {
&& ! localStorage.getItem(muteStore)) {
// Volume was just lowered to 0
localStorage.setItem(muteStore, true);
source.muted = true;
this.toggleButtonState(this._volumeButton);
} else if (source.volume !== 0
&& localStorage.getItem(muteStore)) {
// Volume was just raised from 0
localStorage.removeItem(muteStore);
source.muted = false;
this.toggleButtonState(this._volumeButton);
}
});