Skip to content

Commit

Permalink
Merge pull request newscorp-ghfb#935 from newscorp-ghfb/fix/audio-pla…
Browse files Browse the repository at this point in the history
…yer-composable-loops-in-firefox

fix: AudioPlayerComposable - Prevent loop in firefox
  • Loading branch information
lhaggar authored Sep 17, 2024
2 parents ef97927 + 9e729c9 commit 15a5bf9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/audio-player-composable/audio-player-composable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ export const AudioPlayerComposable = ({
// 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;
}

setCurrentTime(0);
setDisplayDuration(0);
}, [src, initialTime, duration]);
}, [src, initialTime]);

const {
audioEvents,
Expand Down

0 comments on commit 15a5bf9

Please sign in to comment.