Skip to content

Commit d648476

Browse files
authored
Fix audio player (#13851)
1 parent cb2151d commit d648476

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

packages/mobile/src/components/audio/AudioPlayer.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,10 @@ export const AudioPlayer = () => {
593593
}
594594
}, [])
595595

596+
// Single subscription with cleanup on unmount only. handlePlayerStateChange
597+
// is stable (useCallback with [] deps) and only uses refs/TrackPlayer, so
598+
// we avoid re-running this effect to prevent removing the listener during
599+
// track switches (which can break playback when playing a second track).
596600
useEffect(() => {
597601
const subscription = TrackPlayer.addEventListener(
598602
Event.PlaybackState,
@@ -602,7 +606,8 @@ export const AudioPlayer = () => {
602606
return () => {
603607
subscription.remove()
604608
}
605-
}, [handlePlayerStateChange])
609+
// eslint-disable-next-line react-hooks/exhaustive-deps -- intentional: register once, cleanup on unmount only
610+
}, [])
606611

607612
// Seek handler
608613
useEffect(() => {

0 commit comments

Comments
 (0)