Commit 5244a5b7 authored by Stanisław Chmiela's avatar Stanisław Chmiela
Browse files

Add _fullscreen property to the view

parent 9be76e36
Loading
Loading
Loading
Loading
+50 −0
Changes for RCTVideo.m: 50 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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 )