From b3abf6e273a69fdfc7b15bcfd17c882bdd3fdc7c Mon Sep 17 00:00:00 2001 From: Hans Date: Sat, 23 Nov 2024 00:25:58 +0800 Subject: [PATCH] feat(iOS): support restore play from background --- ios/ReactNativeVideoPlayerView.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ios/ReactNativeVideoPlayerView.mm b/ios/ReactNativeVideoPlayerView.mm index 17bc263..73ed6f1 100644 --- a/ios/ReactNativeVideoPlayerView.mm +++ b/ios/ReactNativeVideoPlayerView.mm @@ -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]; }); } @@ -125,6 +129,13 @@ - (void)prepareForRecycle #endif } +- (void)restorePlay:(NSNotification *)notification +{ + if (!_paused) { + [_player play]; + } +} + - (void)_release { [[NSNotificationCenter defaultCenter] removeObserver:self];