fix(ui): prevent duplicate wheel listeners and correct mute handling
- Remove stacked wheel event listeners on fullscreen reopen to avoid multiple handler executions. - Replace non-existent Player mute methods with audioPlayer.muted property and localStorage update. - Ensures volume wheel and mute logic work correctly after multiple fullscreen toggles.
This commit is contained in:
parent
277d8e801b
commit
7cf0b3d386
1 changed files with 10 additions and 5 deletions
15
js/ui.js
15
js/ui.js
|
|
@ -1351,17 +1351,22 @@ export class UIRenderer {
|
||||||
const currentVolume = this.player.userVolume;
|
const currentVolume = this.player.userVolume;
|
||||||
const newVolume = Math.max(0, Math.min(1, currentVolume + delta));
|
const newVolume = Math.max(0, Math.min(1, currentVolume + delta));
|
||||||
|
|
||||||
if (delta > 0 && this.player.muted) {
|
if (delta > 0 && audioPlayer.muted) {
|
||||||
this.player.setMute(false);
|
audioPlayer.muted = false;
|
||||||
|
localStorage.setItem('muted', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.player.setVolume(newVolume);
|
this.player.setVolume(newVolume);
|
||||||
updateFsVolumeUI();
|
updateFsVolumeUI();
|
||||||
};
|
};
|
||||||
|
|
||||||
[fsVolumeBar, fsVolumeBtn].forEach((el) =>
|
[fsVolumeBar, fsVolumeBtn].forEach((el) => {
|
||||||
el.addEventListener('wheel', handleFsVolumeWheel, { passive: false })
|
if (el._fsVolumeWheelHandler) {
|
||||||
);
|
el.removeEventListener('wheel', el._fsVolumeWheelHandler);
|
||||||
|
}
|
||||||
|
el._fsVolumeWheelHandler = handleFsVolumeWheel;
|
||||||
|
el.addEventListener('wheel', handleFsVolumeWheel, { passive: false });
|
||||||
|
});
|
||||||
|
|
||||||
const setFsVolume = (e) => {
|
const setFsVolume = (e) => {
|
||||||
const rect = fsVolumeBar.getBoundingClientRect();
|
const rect = fsVolumeBar.getBoundingClientRect();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue