🐛 Bug: onEnd fires multiple times after re-render on iOS
Description
The onEnd callback is triggered more than once for the same video on iOS when the component re-renders. This leads to unintended side effects such as multiple "play next" actions being fired.
Environment
- Platform: iOS
- Library: react-native-video
- Version: ^6.19.1
- React Native version: 0.83.4
- Device: real device
Expected Behavior
onEnd should fire exactly once when the video playback reaches the end.
Actual Behavior
onEnd fires multiple times:
- once when the video ends
- again after a re-render (e.g. state update, focus change, or parent re-render)
Reproduction
- Render a
<Video /> component
- Let the video play until completion
- Trigger a re-render (e.g. via state change or switching focus)
- Observe that
onEnd fires again
Minimal Example
const handleEnd = () => {
console.log("onEnd triggered");
};
<Video
source={{ uri: videoUrl }}
onEnd={handleEnd}
/>
Notes / Observations
Workarounds Tried
if (endedVideoIdsRef.current.has(videoId)) return;
- Checking active video before handling:
if (videoId !== focusedQueuedVideoId) return;
- Manually seeking to
0 on focus:
videoRef.current?.seek(0);
These mitigate the issue but do not address the root cause.
Additional Context
This behavior makes it difficult to reliably implement queue-based playback (e.g. auto-playing next video), since onEnd cannot be treated as a single-fire event.
Possible Cause (Speculation)
The player may re-emit onEnd when:
- the component re-renders while the playback position is at the end
- the native player re-attaches or updates state
Request
- Confirm whether this is expected behavior
- Provide a way to ensure
onEnd fires only once per playback cycle
- Or expose a more reliable "playback completed" signal
🐛 Bug:
onEndfires multiple times after re-render on iOSDescription
The
onEndcallback is triggered more than once for the same video on iOS when the component re-renders. This leads to unintended side effects such as multiple "play next" actions being fired.Environment
Expected Behavior
onEndshould fire exactly once when the video playback reaches the end.Actual Behavior
onEndfires multiple times:Reproduction
<Video />componentonEndfires againMinimal Example
Notes / Observations
It may be related to the player staying at the end position and re-triggering
onEndon re-renderHappens more frequently when:
Workarounds Tried
0on focus:These mitigate the issue but do not address the root cause.
Additional Context
This behavior makes it difficult to reliably implement queue-based playback (e.g. auto-playing next video), since
onEndcannot be treated as a single-fire event.Possible Cause (Speculation)
The player may re-emit
onEndwhen:Request
onEndfires only once per playback cycle