fix toggle UI console errors + volume button disappearing for no reason

This commit is contained in:
Samidy 2026-03-11 08:36:11 +03:00
parent d167a9c869
commit 07003f92f0
2 changed files with 31 additions and 0 deletions

View file

@ -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);
}

View file

@ -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();