diff options
author | Grant Shangreaux <shshoshin@protonmail.com> | 2020-01-06 14:11:12 -0600 |
---|---|---|
committer | Grant Shangreaux <shshoshin@protonmail.com> | 2020-01-06 14:11:12 -0600 |
commit | c4eb36eb96f03f399cb843ac091e09f233d1b4d4 (patch) | |
tree | f04b48868e07a2c639737ef6e835cfe85529cc77 /tape-deck.js | |
parent | a24319df553a1bc55676c5d07e3c56e7168fb8f7 (diff) |
Fix: notes updating maybe? Add: button press sound
Diffstat (limited to 'tape-deck.js')
-rw-r--r-- | tape-deck.js | 9 |
1 files changed, 6 insertions, 3 deletions
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); }); |