diff options
Diffstat (limited to 'tape-deck.js')
-rw-r--r-- | tape-deck.js | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/tape-deck.js b/tape-deck.js index 631de23..f730600 100644 --- a/tape-deck.js +++ b/tape-deck.js @@ -5,13 +5,6 @@ const tape = new Audio(`audio/2019-mix-side-${currentSide}.mp3`); const pressPlaySound = new Audio("audio/tape-start.mp3"); const buttonPressSound = new Audio("audio/button-press.mp3"); pressPlaySound.onended = (event) => { tape.play(); }; -buttonPressSound.onended = (event) => { - if (isPlaying()) { - playing = false; - } else { - tape.play(); - } -}; const stopImage = "images/cool-deck.png"; const playImage = "images/cool-deck.gif"; @@ -25,11 +18,7 @@ let notes = document.getElementById("notes"); let trackData = []; let currentTrackIndex = 0; let hasStarted = false; -let playing = false; - -function isPlaying() { - return playing; -} +let isPlaying = false; function loadTrackData() { fetch(`side${currentSide}.json`) @@ -40,11 +29,12 @@ function loadTrackData() { } function play() { - if (isPlaying()) { + if (isPlaying) { playButton.src = playButtonUp; buttonPressSound.play(); tape.pause(); deck.src = stopImage; + isPlaying = false; return; } @@ -53,9 +43,10 @@ function play() { hasStarted = true; } else { buttonPressSound.play(); + tape.play(); } - playing = true; + isPlaying = true; playButton.src = playButtonDown; deck.src = playImage; } |