diff --git a/Video 84 - Project 2 - Spotify Clone/js/script.js b/Video 84 - Project 2 - Spotify Clone/js/script.js index 32e76b89..a54ccc26 100644 --- a/Video 84 - Project 2 - Spotify Clone/js/script.js +++ b/Video 84 - Project 2 - Spotify Clone/js/script.js @@ -138,8 +138,13 @@ async function main() { // Listen for timeupdate event currentSong.addEventListener("timeupdate", () => { - document.querySelector(".songtime").innerHTML = `${secondsToMinutesSeconds(currentSong.currentTime)} / ${secondsToMinutesSeconds(currentSong.duration)}` - document.querySelector(".circle").style.left = (currentSong.currentTime / currentSong.duration) * 100 + "%"; + let timetake = secondsToMinutesSeconds(currentSong.currentTime) + let totaltime = secondsToMinutesSeconds(currentSong.duration) + document.querySelector(".songtime").innerHTML = timetake + ' / ' + totaltime; + document.querySelector(".circle").style.left = (currentSong.currentTime / currentSong.duration) * 100 + '%'; + if (timetake == totaltime) { + play.src = "img/play.svg" + } }) // Add an event listener to seekbar @@ -210,4 +215,4 @@ async function main() { } -main() \ No newline at end of file +main()