]> littlesong.place Git - littlesongplace.git/commitdiff
Fix play/pause button image
authorChris Fulljames <christianfulljames@gmail.com>
Thu, 30 Jan 2025 01:20:21 +0000 (20:20 -0500)
committerChris Fulljames <christianfulljames@gmail.com>
Thu, 30 Jan 2025 01:20:21 +0000 (20:20 -0500)
static/player.js

index 4bc089992bf381244cfe434a191714cf0e67a358..9b37b92a7c49ab6d4792ed43cc8d7699456a26af 100644 (file)
@@ -42,13 +42,10 @@ function playCurrentSong() {
 // Play or pause the current song in the player
 function songPlayPause() {
     var audio = document.getElementById("player-audio");
-    var button = document.getElementById("play-pause-button");
     if (audio.paused) {
-        button.src = "/static/lsp_btn_pause.gif";
         audio.play();
     }
     else {
-        button.src = "/static/lsp_btn_play.gif";
         audio.pause();
     }
 }
@@ -159,6 +156,17 @@ document.addEventListener("DOMContentLoaded", (event) => {
     // Next song on audio playback end
     audio.addEventListener("ended", songNext);
 
+    // Show pause button when audio is playing
+    var button = document.getElementById("play-pause-button");
+    audio.addEventListener("play", (event) => {
+        button.src = "/static/lsp_btn_pause.gif";
+    })
+
+    // Show play button when audio is paused
+    audio.addEventListener("pause", (event) => {
+        button.src = "/static/lsp_btn_play.gif";
+    })
+
     // Audio position scrubbing
     var playerPosition = document.getElementById("player-position");
     playerPosition.addEventListener("mousedown", songScrub);