Skip to content

Commit

Permalink
fix(921): revert and remove duration as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
lukejsikuade authored and lhaggar committed Sep 17, 2024
1 parent 44b7fd0 commit 9e729c9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/audio-player-composable/audio-player-composable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9e729c9

Please sign in to comment.