Skip to content

Commit

Permalink
[video][ios] Fix unable to call presentFullScreenPlayer twice (expo#8343
Browse files Browse the repository at this point in the history
)

Fixes an issue when calling `presentFullScreenPlayer` more than once on iOS. This would result in the error “Fullscreen player is already being presented” when the `useNativeControls` prop also set on the `<Video>` component.

When useNativeControls is set, it re-creates the PlayerViewController every time the full-screen view-controller was closed. This caused the “videoBounds” key-value handler to be called which incorrectly assumed the regular ViewController was transitioning from full-screen to non full-screen. An additional check has been added to ensure this detection is not triggered when the full-screen viewcontroller is used.
  • Loading branch information
IjzerenHein committed May 19, 2020
1 parent 2ce3b40 commit 2fbbf95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,4 +8,5 @@

### 🐛 Bug fixes

- Fix unable to call presentFullScreenPlayer twice. ([#8343](https://github.com/expo/expo/pull/8343) by [@IjzerenHein](https://github.com/IjzerenHein))
- Fixed `Plaback.loadAsync()` return type. ([#7559](https://github.com/expo/expo/pull/7559) by [@awinograd](https://github.com/awinograd))
6 changes: 3 additions & 3 deletions ios/EXAV/Video/EXVideoView.m
Expand Up @@ -243,14 +243,14 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
CGRect viewBounds = [change[@"new"] CGRectValue];
CGRect screen = [[UIScreen mainScreen] bounds];

if (viewBounds.size.height != screen.size.height && viewBounds.size.width != screen.size.width && _fullscreenPlayerPresented) {
if (viewBounds.size.height != screen.size.height && viewBounds.size.width != screen.size.width && _fullscreenPlayerPresented && !_fullscreenPlayerViewController) {
// Fullscreen player is being dismissed
_fullscreenPlayerPresented = false;
_fullscreenPlayerPresented = NO;
[self _callFullscreenCallbackForUpdate:EXVideoFullscreenUpdatePlayerWillDismiss];
[self _callFullscreenCallbackForUpdate:EXVideoFullscreenUpdatePlayerDidDismiss];
} else if (viewBounds.size.height == screen.size.height && viewBounds.size.width == screen.size.width && !_fullscreenPlayerPresented) {
// Fullscreen player is being presented
_fullscreenPlayerPresented = true;
_fullscreenPlayerPresented = YES;
[self _callFullscreenCallbackForUpdate:EXVideoFullscreenUpdatePlayerWillPresent];
[self _callFullscreenCallbackForUpdate:EXVideoFullscreenUpdatePlayerDidPresent];
} else {
Expand Down

0 comments on commit 2fbbf95

Please sign in to comment.