Skip to content

Commit

Permalink
feat(iOS): support restore play from background
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Nov 22, 2024
1 parent 1306d32 commit b3abf6e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ios/ReactNativeVideoPlayerView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ - (void)initCommon:(UIView *)view
selector:@selector(playerItemDidPlayToEndTime:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(restorePlay:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
});
}

Expand Down Expand Up @@ -125,6 +129,13 @@ - (void)prepareForRecycle
#endif
}

- (void)restorePlay:(NSNotification *)notification
{
if (!_paused) {
[_player play];
}
}

- (void)_release
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
Expand Down

0 comments on commit b3abf6e

Please sign in to comment.