From 504ec387bf8250ad33e85102f7cd129ce3fd790d Mon Sep 17 00:00:00 2001 From: Nikita Likhachev Date: Thu, 22 Dec 2022 13:07:06 +0700 Subject: [PATCH] iOS app crashes on call to presentFullScreenPlayer #2808 --- ios/Video/RCTVideo.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 769baba7..9bcf237a 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -635,14 +635,16 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH self.onVideoFullscreenPlayerWillPresent?(["target": reactTag as Any]) - viewController.present(viewController, animated:true, completion:{ - self._playerViewController?.showsPlaybackControls = true - self._fullscreenPlayerPresented = fullscreen - self._playerViewController?.autorotate = self._fullscreenAutorotate + if let playerViewController = _playerViewController { + viewController.present(playerViewController, animated:true, completion:{ + self._playerViewController?.showsPlaybackControls = true + self._fullscreenPlayerPresented = fullscreen + self._playerViewController?.autorotate = self._fullscreenAutorotate - self.onVideoFullscreenPlayerDidPresent?(["target": self.reactTag]) + self.onVideoFullscreenPlayerDidPresent?(["target": self.reactTag]) - }) + }) + } } } else if !fullscreen && _fullscreenPlayerPresented, let _playerViewController = _playerViewController { self.videoPlayerViewControllerWillDismiss(playerViewController: _playerViewController)