From c4eb36eb96f03f399cb843ac091e09f233d1b4d4 Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Mon, 6 Jan 2020 14:11:12 -0600 Subject: Fix: notes updating maybe? Add: button press sound --- audio/button-press.mp3 | Bin 0 -> 13895 bytes tape-deck.js | 9 ++++++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 audio/button-press.mp3 diff --git a/audio/button-press.mp3 b/audio/button-press.mp3 new file mode 100644 index 0000000..1474d3f Binary files /dev/null and b/audio/button-press.mp3 differ diff --git a/tape-deck.js b/tape-deck.js index 3d10fe8..230d3c8 100644 --- a/tape-deck.js +++ b/tape-deck.js @@ -11,6 +11,7 @@ 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"); @@ -40,11 +41,13 @@ function play() { pressPlaySound.play(); hasStarted = true; } else { + buttonPressSound.play(); tape.play(); } isPlaying = true; playButton.src = playButtonDown; + buttonPressSound.play(); deck.src = playImage; } @@ -52,7 +55,7 @@ function isLastTrack(current, tracks) { return current + 1 === tracks.length; } -function getTrack(time, currentTrackIndex, trackData) { +function getTrack(time) { const nextIndex = currentTrackIndex + 1; const startTimes = trackData.map( t => t.start ); @@ -70,7 +73,7 @@ function getTrack(time, currentTrackIndex, trackData) { function formatTrackData(track) { let string = `${track.title} - ${track.artist}`; if (track.album) { - string = string.concat(` - ${track.album}`) + string = string.concat(` - ${track.album}`); } if (track.link) { @@ -84,6 +87,6 @@ loadTrackData(); tape.addEventListener("timeupdate", (event) => { const time = tape.currentTime; - const currentTrack = getTrack(time, currentTrackIndex, trackData); + const currentTrack = getTrack(time); notes.textContent = formatTrackData(currentTrack); }); -- cgit v1.2.3