summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Shangreaux <shshoshin@protonmail.com>2020-01-06 14:11:12 -0600
committerGrant Shangreaux <shshoshin@protonmail.com>2020-01-06 14:11:12 -0600
commitc4eb36eb96f03f399cb843ac091e09f233d1b4d4 (patch)
treef04b48868e07a2c639737ef6e835cfe85529cc77
parenta24319df553a1bc55676c5d07e3c56e7168fb8f7 (diff)
Fix: notes updating maybe? Add: button press sound
-rw-r--r--audio/button-press.mp3bin0 -> 13895 bytes
-rw-r--r--tape-deck.js9
2 files changed, 6 insertions, 3 deletions
diff --git a/audio/button-press.mp3 b/audio/button-press.mp3
new file mode 100644
index 0000000..1474d3f
--- /dev/null
+++ b/audio/button-press.mp3
Binary files 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);
});