fix js variable reference error on loading the audio player component

This commit is contained in:
Nuwan 2024-12-27 13:21:38 +05:30
parent 6368897b21
commit 04a7445f68
1 changed files with 39 additions and 38 deletions

View File

@ -110,7 +110,6 @@ const JKAudioPlayer = ({ audioUrl }) => {
audioPlayer.current.querySelector(".controls .volume-percentage").style.width = volume * 100 + '%'; audioPlayer.current.querySelector(".controls .volume-percentage").style.width = volume * 100 + '%';
} }
function getTimeCodeFromNum(num) { function getTimeCodeFromNum(num) {
let seconds = parseInt(num); let seconds = parseInt(num);
let minutes = parseInt(seconds / 60); let minutes = parseInt(seconds / 60);
@ -125,6 +124,7 @@ const JKAudioPlayer = ({ audioUrl }) => {
} }
return ( return (
audioUrl && audio && (
<div className="audio-player" ref={audioPlayer}> <div className="audio-player" ref={audioPlayer}>
<div className="controls"> <div className="controls">
@ -132,7 +132,6 @@ const JKAudioPlayer = ({ audioUrl }) => {
<button <button
onClick={togglePlayPause} onClick={togglePlayPause}
className="play-pause-button" className="play-pause-button"
> >
{isPlaying ? ( {isPlaying ? (
<img src={pauseIcon} alt="Pause" width="30" /> <img src={pauseIcon} alt="Pause" width="30" />
@ -168,6 +167,8 @@ const JKAudioPlayer = ({ audioUrl }) => {
</div> </div>
</div> </div>
) )
);
} }
export default JKAudioPlayer export default JKAudioPlayer