[Glitch] Fix confusing behavior of mute button and volume slider in web UI
Port 91040da871
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
58514651c3
commit
263d601c25
2 changed files with 10 additions and 8 deletions
|
@ -212,11 +212,11 @@ class Audio extends PureComponent {
|
|||
};
|
||||
|
||||
toggleMute = () => {
|
||||
const muted = !this.state.muted;
|
||||
const muted = !(this.state.muted || this.state.volume === 0);
|
||||
|
||||
this.setState({ muted }, () => {
|
||||
this.setState((state) => ({ muted, volume: Math.max(state.volume || 0.5, 0.05) }), () => {
|
||||
if (this.gainNode) {
|
||||
this.gainNode.gain.value = muted ? 0 : this.state.volume;
|
||||
this.gainNode.gain.value = this.state.muted ? 0 : this.state.volume;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -294,7 +294,7 @@ class Audio extends PureComponent {
|
|||
const { x } = getPointerPosition(this.volume, e);
|
||||
|
||||
if(!isNaN(x)) {
|
||||
this.setState({ volume: x }, () => {
|
||||
this.setState((state) => ({ volume: x, muted: state.muted && x === 0 }), () => {
|
||||
if (this.gainNode) {
|
||||
this.gainNode.gain.value = this.state.muted ? 0 : x;
|
||||
}
|
||||
|
|
|
@ -220,8 +220,9 @@ class Video extends PureComponent {
|
|||
const { x } = getPointerPosition(this.volume, e);
|
||||
|
||||
if(!isNaN(x)) {
|
||||
this.setState({ volume: x }, () => {
|
||||
this.setState((state) => ({ volume: x, muted: state.muted && x === 0 }), () => {
|
||||
this.video.volume = x;
|
||||
this.video.muted = this.state.muted;
|
||||
});
|
||||
}
|
||||
}, 15);
|
||||
|
@ -428,10 +429,11 @@ class Video extends PureComponent {
|
|||
};
|
||||
|
||||
toggleMute = () => {
|
||||
const muted = !this.video.muted;
|
||||
const muted = !(this.video.muted || this.state.volume === 0);
|
||||
|
||||
this.setState({ muted }, () => {
|
||||
this.video.muted = muted;
|
||||
this.setState((state) => ({ muted, volume: Math.max(state.volume || 0.5, 0.05) }), () => {
|
||||
this.video.volume = this.state.volume;
|
||||
this.video.muted = this.state.muted;
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue