fix: _paused is updated when video playback pause #4320
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Keep paused state in sync with playing state.
Motivation
I found that the video resumes from being paused automatically when foregrounding the app, which is an unexpected behavior. I wanted the playback state from the background, whether playing or paused, to persist from background to foreground to create a better experience for the users of my app.
Also a fix for #4321
Changes
Update
_paused
on RCTVideo alongside_isPlaying
when the video playback (or time control status) changes.I found that this was behavior was due to
_paused
on RCTVideo not being updated when the video is paused with native controls, as it is only updated by thesetPause()
method. The consequences of this are thatsetPause()
is called withinapplyModifiers()
which is called withinapplicationWillEnterForeground().
This call uses the current value of_paused
(setPause(_paused)
), which is false, andsetPause()
will play the video if the value given to it is false.Updating
_paused
alongside_isPlaying
keeps it update with the state of the player and fixes the issue.Test plan