Skip to content

Commit

Permalink
Add try test
Browse files Browse the repository at this point in the history
  • Loading branch information
wozandy05 committed Mar 16, 2024
1 parent 3f7fe41 commit f3023a0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ const timeFormatter = (timeInput) => {
const setSong = (arrayIndex) => {
//this extracts all the variables from the object
let { name, src, artist, img } = songsList[arrayIndex];
audio.src = 'https://colddb.netlify.app/audio/' + src + ".mp3";
try {
audio.src = 'https://colddb.netlify.app/audio/' + src + ".mp3";
songImage.src = 'https://colddb.netlify.app/images/' + img + '.jpg';
} catch(err) {
console.log(err);
}

songName.innerHTML = name;
songArtist.innerHTML = artist;
songImage.src = 'https://colddb.netlify.app/images/' + img + '.jpg';
//display duration when metadata loads
audio.onloadedmetadata = () => {
maxDuration.innerText = timeFormatter(audio.duration);
Expand Down

0 comments on commit f3023a0

Please sign in to comment.