From 5244a5b797f4b4d4c1b84b6144f995854560c256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw=20Chmiela?= Date: Thu, 31 Mar 2016 20:34:22 +0200 Subject: [PATCH] Add _fullscreen property to the view --- RCTVideo.m | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/RCTVideo.m b/RCTVideo.m index 7bd52933..268c4dab 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -37,6 +37,8 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; BOOL _paused; BOOL _repeat; NSString * _resizeMode; + BOOL _fullScreenPlayerPresented; + UIViewController * _presentingViewController; } - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher @@ -425,6 +427,54 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; _repeat = repeat; } +- (BOOL)getFullscreen +{ + return _fullScreenPlayerPresented; +} + +- (void)setFullscreen:(BOOL)fullscreen +{ + if( fullscreen ) + { + // Ensure player view controller is not null + if( !_playerViewController ) + { + [self usePlayerViewController]; + } + // Set presentation style to fullscreen + [_playerViewController setModalPresentationStyle:UIModalPresentationOverFullScreen]; + + // Find the nearest view controller + UIViewController *viewController = [self firstAvailableUIViewController]; + if( !viewController ) + { + UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; + viewController = keyWindow.rootViewController; + if( viewController.childViewControllers.count > 0 ) + { + viewController = viewController.childViewControllers.lastObject; + } + } + if( viewController ) + { + _presentingViewController = viewController; + [viewController presentViewController:_playerViewController animated:true completion:^{ + _playerViewController.showsPlaybackControls = YES; + _fullScreenPlayerPresented = fullscreen; + }]; + + } + } + else + { + [_presentingViewController dismissViewControllerAnimated:true completion:^{ + _fullScreenPlayerPresented = fullscreen; + _presentingViewController = nil; + }]; + } +} + + - (void)usePlayerViewController { if( _player )