From 3ba26eb45a7b6602c5051e2a20e272afcad25852 Mon Sep 17 00:00:00 2001 From: Ash Mishra Date: Thu, 2 Aug 2018 10:32:50 -0700 Subject: [PATCH] Working on autorotation of video player --- ios/Video/RCTVideo.m | 9 +++++---- ios/Video/RCTVideoPlayerViewController.m | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index 9fe30b63..3b04e4e5 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -61,6 +61,7 @@ static int const RCTVideoUnset = -1; BOOL _playWhenInactive; NSString * _ignoreSilentSwitch; NSString * _resizeMode; + BOOL _fullscreen; BOOL _fullscreenPlayerPresented; UIViewController * _presentingViewController; #if __has_include() @@ -341,6 +342,8 @@ static int const RCTVideoUnset = -1; _playbackRateObserverRegistered = YES; [self addPlayerTimeObserver]; + + [self setFullscreen:_fullscreen]; //Perform on next run loop, otherwise onVideoLoadStart is nil if (self.onVideoLoadStart) { @@ -1085,10 +1088,8 @@ static int const RCTVideoUnset = -1; - (void)setFullscreen:(BOOL)fullscreen { - if( fullscreen && !_fullscreenPlayerPresented ) - { - // Ensure player view controller is not null - if( !_playerViewController ) + _fullscreen = fullscreen; + if( fullscreen && !_fullscreenPlayerPresented && _player ) { [self usePlayerViewController]; } diff --git a/ios/Video/RCTVideoPlayerViewController.m b/ios/Video/RCTVideoPlayerViewController.m index 7809221a..12480d54 100644 --- a/ios/Video/RCTVideoPlayerViewController.m +++ b/ios/Video/RCTVideoPlayerViewController.m @@ -13,4 +13,18 @@ [_rctDelegate videoPlayerViewControllerDidDismiss:self]; } +- (BOOL)shouldAutorotate { + return YES; +} + +- (UIInterfaceOrientationMask)supportedInterfaceOrientations { + + return UIInterfaceOrientationMaskLandscape; +} + +- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { + + return UIInterfaceOrientationLandscapeLeft; +} + @end