From 9e729c901cfdcc2ba2f6501625314bf81e35e11e Mon Sep 17 00:00:00 2001 From: lukejsikuade Date: Thu, 7 Mar 2024 15:13:18 +0000 Subject: [PATCH] fix(921): revert and remove duration as dependency --- .../audio-player-composable.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/audio-player-composable/audio-player-composable.tsx b/src/audio-player-composable/audio-player-composable.tsx index 4f60a60eb..544bef7a8 100644 --- a/src/audio-player-composable/audio-player-composable.tsx +++ b/src/audio-player-composable/audio-player-composable.tsx @@ -73,20 +73,18 @@ export const AudioPlayerComposable = ({ currentTimeRef.current = currentTime; }); - useEffect(() => { - setCurrentTime(0); - setDisplayDuration(0); - }, [src]); - useEffect(() => { // On render onTimeUpdate will be fired and initialTime will be set as a value for currentTime state. // I can't set this one to the setCurrentTime state directly as the audioElement time // will still be 0, currentTime will be overridden to 0 and the audio will start from 0 - if (audioRef && audioRef.current && duration) { + if (audioRef && audioRef.current) { audioRef.current.currentTime = initialTime; } - }, [duration, initialTime]); + + setCurrentTime(0); + setDisplayDuration(0); + }, [src, initialTime]); const { audioEvents,