commit 6ba6600f5ad2a96fdeed9c597a2763a280cdbb3f
parent 34e37fe4ecedefa254d1029ecc2f62718f3bee43
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 8 Mar 2021 14:05:17 +0100
parent 34e37fe4ecedefa254d1029ecc2f62718f3bee43
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 8 Mar 2021 14:05:17 +0100
webmusic.js: check for playable content
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/webmusic.js b/webmusic.js @@ -7,12 +7,14 @@ let playerState = 'idle'; let continuous = true; let repeat = false; let total = 0; +let onlyDirs = true; const handleKeyEvent = (event) => { if (event.ctrlKey === true || event.altKey === true) return; switch (event.key) { case ' ': case 'p': + if (onlyDirs !== false) return; if (playerState == 'idle' && total !== 0) { if (document.getElementById(playingItem).classList.contains('dir')) { return nextTrack(); @@ -72,7 +74,6 @@ const handleKeyEvent = (event) => { case '9': audioPlayer.currentTime = audioPlayer.duration / 100 * (event.key * 10); break; - } }; @@ -116,6 +117,7 @@ const initState = () => { fileElements.forEach((element) => { element.id = id++; + onlyDirs = false; element.addEventListener('click', (event) => { event.preventDefault();