From f54dc303b751722b7c9616141de102a6cb6c4d1d Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Mon, 6 Jan 2020 14:24:49 -0600 Subject: Fix: timing of button press sound on play --- tape-deck.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tape-deck.js b/tape-deck.js index e0ee376..7485c92 100644 --- a/tape-deck.js +++ b/tape-deck.js @@ -3,7 +3,9 @@ const currentSide = urlParams.get("side"); 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) => { tape.play(); }; const stopImage = "images/cool-deck.png"; const playImage = "images/cool-deck.gif"; @@ -11,7 +13,6 @@ const playImage = "images/cool-deck.gif"; let playButton = document.getElementById("play-button"); const playButtonUp = "images/play-button-up.png"; const playButtonDown = "images/play-button-down.png"; -const buttonPressSound = new Audio("audio/button-press.mp3"); let deck = document.getElementById("tape-deck"); let notes = document.getElementById("notes"); @@ -43,7 +44,6 @@ function play() { hasStarted = true; } else { buttonPressSound.play(); - tape.play(); } isPlaying = true; -- cgit v1.2.3