diff --git a/jam-ui/src/components/jamtracks/JKAudioPlayer.js b/jam-ui/src/components/jamtracks/JKAudioPlayer.js index 671312417..c2dd93a96 100644 --- a/jam-ui/src/components/jamtracks/JKAudioPlayer.js +++ b/jam-ui/src/components/jamtracks/JKAudioPlayer.js @@ -23,7 +23,9 @@ const JKAudioPlayer = ({ audioUrl }) => { useEffect(() => { if (!audio || !audioPlayer) return; - stopAudio(); + if(audio){ + stopAudio(); + } const audioLoadedDataEventListener = audio.addEventListener("loadeddata", () => { audioPlayer.current.querySelector(".time .length").textContent = getTimeCodeFromNum( audio.duration @@ -42,9 +44,11 @@ const JKAudioPlayer = ({ audioUrl }) => { //audio.play(); return () => { - stopAudio(); - audio.removeEventListener("loadeddata", audioLoadedDataEventListener); - clearInterval(audioPercentageCheckInterval); + if(audio){ + stopAudio(); + audio.removeEventListener("loadeddata", audioLoadedDataEventListener); + clearInterval(audioPercentageCheckInterval); + } } }, [audio, audioPlayer]);