summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeah (ctucx) <leah@ctu.cx>2021-03-07 16:10:01 +0100
committerLeah (ctucx) <leah@ctu.cx>2021-03-07 16:10:01 +0100
commita40d6abb35e143dd2e13900a2e65a056379f8f9e (patch)
treeb69b5cca974974f28bd72bdf52cdc031cd555ba7
parentd1c43ca7044dcbb35733edb773a254f7829435de (diff)
downloadwebmusic-nginx-a40d6abb35e143dd2e13900a2e65a056379f8f9e.tar.gz
webmusic-nginx-a40d6abb35e143dd2e13900a2e65a056379f8f9e.tar.bz2
webmusic-nginx-a40d6abb35e143dd2e13900a2e65a056379f8f9e.zip
webmusic.js: removed debug prints, better player handling
-rw-r--r--webmusic.js16
1 files changed, 6 insertions, 10 deletions
diff --git a/webmusic.js b/webmusic.js
index 5e8f819..ef1ab48 100644
--- a/webmusic.js
+++ b/webmusic.js
@@ -80,7 +80,6 @@ const initState = () => {
});
audioPlayer.addEventListener("ended", function () {
- console.log("end track: " + index);
setPlayerState("idle");
nextTrack();
});
@@ -142,7 +141,6 @@ const updateButtonState = () => {
const playSong = (id) => {
- console.log("track id:" +id)
let element = document.getElementById(id);
if (element === null) return;
@@ -155,11 +153,11 @@ const playSong = (id) => {
index = element.id;
audioPlayer.pause()
+
audioPlayer.src = element.href;
setPlayerState("loading");
-
- audioPlayer.loop = repeat;
+ audioPlayer.load();
element.classList.add("playing");
}
@@ -185,27 +183,25 @@ const toggleContinue = () => {
}
const previousTrack = () => {
+ if (!continuous) return;
if (index-- === 0) index = total-1;
if (document.getElementById(index).classList.contains('dir')) {
return previousTrack();
}
- if (continuous) {
- playSong(index)
- }
+ playSong(index);
}
const nextTrack = () => {
+ if (!continuous) return;
if (++index === total) index = 0;
if (document.getElementById(index).classList.contains('dir')) {
return nextTrack();
}
- if (continuous) {
- playSong(index)
- }
+ playSong(index);
}
const formatTime = (secs) => {