From a93992c3907808cfa97074ebbf5b718085406585 Mon Sep 17 00:00:00 2001 From: Hans Date: Tue, 19 Sep 2023 04:22:00 +0800 Subject: [PATCH] fix(iOS): fix video always pause on seek --- ios/ReactNativeVideoPlayerView.mm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ios/ReactNativeVideoPlayerView.mm b/ios/ReactNativeVideoPlayerView.mm index 31bfe6c..038f006 100644 --- a/ios/ReactNativeVideoPlayerView.mm +++ b/ios/ReactNativeVideoPlayerView.mm @@ -113,8 +113,7 @@ -(void)dealloc - (void)playerItemDidPlayToEndTime:(NSNotification *)notification { if (_loop) { - [_player seekToTime:kCMTimeZero]; - [_player play]; + [self seekTo:0]; } else { [self emitOnEnd]; } @@ -183,7 +182,7 @@ - (void)setPaused:(BOOL)paused - (void)setSeek:(Float64)seek { - [_player seekToTime:CMTimeMakeWithSeconds(seek, NSEC_PER_SEC)]; + [self seekTo:seek]; } - (void)setVolume:(float)volume @@ -238,7 +237,13 @@ - (void)pause - (void)seekTo:(Float64)time { - [_player seekToTime:CMTimeMakeWithSeconds(time, NSEC_PER_SEC)]; + [_player seekToTime:CMTimeMakeWithSeconds(time, NSEC_PER_SEC) completionHandler:^(BOOL finished) { + if (finished) { + if (!_paused) { + [_player play]; + } + } + }]; } - (void)stop