From 315f532719195df1a2bfa71eb9f5adb4afe3022d Mon Sep 17 00:00:00 2001 From: Nuwan Date: Fri, 27 Dec 2024 23:29:50 +0530 Subject: [PATCH] fix audio player js ref error --- .../src/components/jamtracks/JKAudioPlayer.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/jam-ui/src/components/jamtracks/JKAudioPlayer.js b/jam-ui/src/components/jamtracks/JKAudioPlayer.js index 58910827c..32387085d 100644 --- a/jam-ui/src/components/jamtracks/JKAudioPlayer.js +++ b/jam-ui/src/components/jamtracks/JKAudioPlayer.js @@ -60,7 +60,7 @@ const JKAudioPlayer = ({ audioUrl }) => { } const togglePlayPause = (e) => { - if (!audio) return; + if (!audio || e === "undefined") return; if (audio.paused) { audio.play(); setIsPlaying(true); @@ -70,14 +70,8 @@ const JKAudioPlayer = ({ audioUrl }) => { } } - const onVolumeButtonClick = () => { - if (!audio) return; - audio.muted = !audio.muted; - setIsMuted(audio.muted); - } - const onClickTimeline = (e) => { - if (!audio) return; + if (!audio || e === "undefined") return; let timeToSeek = 0; try { let timelineWidth = window.getComputedStyle(audioPlayer.current.querySelector(".timeline")).width; @@ -94,7 +88,7 @@ const JKAudioPlayer = ({ audioUrl }) => { } const onVolumeSliderClick = (e) => { - if (!audio) return; + if (!audio || e === "undefined") return; let volume = .75; try { let sliderWidth = window.getComputedStyle(audioPlayer.current.querySelector(".controls .volume-slider")).width; @@ -110,7 +104,13 @@ const JKAudioPlayer = ({ audioUrl }) => { audioPlayer.current.querySelector(".controls .volume-percentage").style.width = volume * 100 + '%'; } - function getTimeCodeFromNum(num) { + const onVolumeButtonClick = () => { + if (!audio) return; + audio.muted = !audio.muted; + setIsMuted(audio.muted); + } + + const getTimeCodeFromNum = (num) => { let seconds = parseInt(num); let minutes = parseInt(seconds / 60); seconds -= minutes * 60;