From 2ae99bd484486f468932db7830b7db8b69ccc507 Mon Sep 17 00:00:00 2001 From: Jan Lievens Date: Tue, 24 Oct 2017 09:47:43 +0200 Subject: [PATCH 1/6] remove observers before adding thus preventing multiple observers for the same notification --- ios/RCTVideo.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 9962c2bb..ab0927c6 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -454,10 +454,17 @@ static NSString *const timedMetadata = @"timedMetadata"; - (void)attachListeners { // listen for end of file + [[NSNotificationCenter defaultCenter] removeObserver:self + name:AVPlayerItemDidPlayToEndTimeNotification + object:[_player currentItem]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[_player currentItem]]; + + [[NSNotificationCenter defaultCenter] removeObserver:self + name:AVPlayerItemPlaybackStalledNotification + object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStalled:) name:AVPlayerItemPlaybackStalledNotification From 28bae40c6c0d5b58bb30c2e56249b91fe7ae115d Mon Sep 17 00:00:00 2001 From: seansy Date: Mon, 19 Mar 2018 12:56:55 -0700 Subject: [PATCH 2/6] Fixes #963 Bug happens when uri is changed for a video. The fix: Remove player layer before addPlayerItemObservers so _playerItemObserversSet is still set to NO if observers have already been removed. --- ios/RCTVideo.m | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 0f1227b1..ab0d5879 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -140,8 +140,8 @@ static NSString *const timedMetadata = @"timedMetadata"; - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - [self removePlayerItemObservers]; [self removePlayerLayer]; + [self removePlayerItemObservers]; [_player removeObserver:self forKeyPath:playbackRate context:nil]; } @@ -252,9 +252,6 @@ static NSString *const timedMetadata = @"timedMetadata"; * observer set */ - (void)removePlayerItemObservers { - if (_playerLayer) { - [_playerLayer removeObserver:self forKeyPath:readyForDisplayKeyPath]; - } if (_playerItemObserversSet) { [_playerItem removeObserver:self forKeyPath:statusKeyPath]; [_playerItem removeObserver:self forKeyPath:playbackBufferEmptyKeyPath]; @@ -268,13 +265,13 @@ static NSString *const timedMetadata = @"timedMetadata"; - (void)setSrc:(NSDictionary *)source { + [self removePlayerLayer]; [self removePlayerTimeObserver]; [self removePlayerItemObservers]; _playerItem = [self playerItemForSource:source]; [self addPlayerItemObservers]; [_player pause]; - [self removePlayerLayer]; [_playerViewController.view removeFromSuperview]; _playerViewController = nil; From a2a7cf14525ffbad428398c26235960ab997aa9b Mon Sep 17 00:00:00 2001 From: Ahmed Barakat Date: Sat, 2 Jun 2018 14:55:55 +0200 Subject: [PATCH 3/6] Fix partial swiping on video shows black screen In iOS 11, Apple added a feature to close the Video Player via a swipe gesture. Partial swiping cases viewWillDisappear to be called without viewDidDisappear which cases a black screen. --- ios/RCTVideoPlayerViewController.m | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ios/RCTVideoPlayerViewController.m b/ios/RCTVideoPlayerViewController.m index 1b7606fd..7809221a 100644 --- a/ios/RCTVideoPlayerViewController.m +++ b/ios/RCTVideoPlayerViewController.m @@ -8,13 +8,9 @@ - (void)viewDidDisappear:(BOOL)animated { - [super viewDidDisappear:animated]; - [_rctDelegate videoPlayerViewControllerDidDismiss:self]; -} - -- (void)viewWillDisappear:(BOOL)animated { - [_rctDelegate videoPlayerViewControllerWillDismiss:self]; - [super viewWillDisappear:animated]; + [super viewDidDisappear:animated]; + [_rctDelegate videoPlayerViewControllerWillDismiss:self]; + [_rctDelegate videoPlayerViewControllerDidDismiss:self]; } @end From ddc1c54325c613f1891e70bc795e071491e93064 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sat, 2 Jun 2018 22:17:44 -0700 Subject: [PATCH 4/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50435ae6..312e5ae0 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ include ':react-native-video' project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer') ``` -If you need to use the old Android media player based player, use the following instead: +If you need to use the old Android MediaPlayer based player, use the following instead: ```gradle include ':react-native-video' From cc823e3fde110003d772ecef2faee1bd5998a050 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sun, 3 Jun 2018 21:11:14 -0700 Subject: [PATCH 5/6] Add iOS swipe bug & iOS switch source crash --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e64caf6..ce2ce416 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Changelog Upcoming release +* Fix doing a partial swipe on iOS causing a black screen (https://github.com/react-native-community/react-native-video/pull/1048) +* Fix crash when switching to a new source on iOS (https://github.com/react-native-community/react-native-video/pull/974) * Add cookie support for ExoPlayer (https://github.com/react-native-community/react-native-video/pull/922) * Remove ExoPlayer onMetadata that wasn't being used (https://github.com/react-native-community/react-native-video/pull/1040) * Fix bug where setting the progress interval on iOS didn't work (https://github.com/react-native-community/react-native-video/pull/800) From b86a2a7e12561ce01bc336947163aea9263c961b Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sun, 3 Jun 2018 21:27:36 -0700 Subject: [PATCH 6/6] Add fix for multiple onEnd notifications on iOS --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce2ce416..81bea39e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Changelog Upcoming release +* Prevent multiple onEnd notifications on iOS (https://github.com/react-native-community/react-native-video/pull/832) * Fix doing a partial swipe on iOS causing a black screen (https://github.com/react-native-community/react-native-video/pull/1048) * Fix crash when switching to a new source on iOS (https://github.com/react-native-community/react-native-video/pull/974) * Add cookie support for ExoPlayer (https://github.com/react-native-community/react-native-video/pull/922)