From 602fe6bbb121e334fb5b7343db137f4fcdeee10a Mon Sep 17 00:00:00 2001 From: Kenneth Date: Sat, 20 Jul 2024 22:57:04 +0100 Subject: [PATCH] feat: go to next song when the current one ends --- web/script.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/script.js b/web/script.js index 2448425..a721d62 100644 --- a/web/script.js +++ b/web/script.js @@ -17,9 +17,14 @@ function playAudio() { }; currentAudio.onpause = () => { isPlaying = false; + volume = 0; playBtn.innerText = "play"; }; - currentAudio.volume = volume; + currentAudio.onended = () => { + volume = 0; + playAudio(); + }; + currentAudio.volume = 0; currentAudio.play(); @@ -31,6 +36,8 @@ function playAudio() { function pauseAudio() { currentAudio.pause(); + currentAudio.volume = 0; + volume = 0; } function fadeIn() {