fix toggle UI console errors + volume button disappearing for no reason
This commit is contained in:
parent
d167a9c869
commit
07003f92f0
2 changed files with 31 additions and 0 deletions
17
js/events.js
17
js/events.js
|
|
@ -384,6 +384,23 @@ export function initializePlayerEvents(player, audioPlayer, scrobbler, ui) {
|
|||
updateWaveform();
|
||||
});
|
||||
|
||||
if (volumeBtn) {
|
||||
volumeBtn.addEventListener('click', () => {
|
||||
const activeEl = player.activeElement;
|
||||
activeEl.muted = !activeEl.muted;
|
||||
localStorage.setItem('muted', activeEl.muted);
|
||||
|
||||
const inactiveEl = player.currentTrack?.type === 'video' ? player.audio : player.video;
|
||||
if (inactiveEl) inactiveEl.muted = activeEl.muted;
|
||||
|
||||
updateVolumeUI();
|
||||
});
|
||||
}
|
||||
const isMuted = localStorage.getItem('muted') === 'true';
|
||||
audioPlayer.muted = isMuted;
|
||||
if (player.video) player.video.muted = isMuted;
|
||||
updateVolumeUI();
|
||||
|
||||
initializeSmoothSliders(player);
|
||||
}
|
||||
|
||||
|
|
|
|||
14
js/ui.js
14
js/ui.js
|
|
@ -1242,6 +1242,20 @@ export class UIRenderer {
|
|||
showButton();
|
||||
}
|
||||
|
||||
const toggleUI = (e) => {
|
||||
if (e) e.stopPropagation();
|
||||
isUIHidden = !isUIHidden;
|
||||
overlay.classList.toggle('ui-hidden', isUIHidden);
|
||||
toggleBtn.classList.toggle('active', isUIHidden);
|
||||
toggleBtn.title = isUIHidden ? 'Show UI' : 'Hide UI';
|
||||
|
||||
if (isUIHidden) {
|
||||
hideButton();
|
||||
} else {
|
||||
showButton();
|
||||
}
|
||||
};
|
||||
|
||||
// Mouse move handler
|
||||
const handleMouseMove = (e) => {
|
||||
const rect = overlay.getBoundingClientRect();
|
||||
|
|
|
|||
Loading…
Reference in a new issue