Loading Video.js +5 −0 Changes for Video.js: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -289,6 +289,11 @@ Video.propTypes = { PropTypes.object ]), fullscreen: PropTypes.bool, fullscreenOptions: PropTypes.shape({ enabled: PropTypes.bool, preferredOrientation: PropTypes.string, autorotate: PropTypes.bool }), onVideoLoadStart: PropTypes.func, onVideoLoad: PropTypes.func, onVideoBuffer: PropTypes.func, Loading ios/Video/RCTVideo.m +41 −6 Changes for ios/Video/RCTVideo.m: 41 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ static int const RCTVideoUnset = -1; NSString * _ignoreSilentSwitch; NSString * _resizeMode; BOOL _fullscreen; NSDictionary* _fullscreenOptions; BOOL _fullscreenPlayerPresented; UIViewController * _presentingViewController; #if __has_include(<react-native-video/RCTVideoCache.h>) Loading Loading @@ -117,9 +118,16 @@ static int const RCTVideoUnset = -1; } - (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem { RCTVideoPlayerViewController* playerLayer= [[RCTVideoPlayerViewController alloc] init]; playerLayer.showsPlaybackControls = YES; playerLayer.rctDelegate = self; if (_fullscreenOptions) { playerLayer.preferredOrientation = [RCTConvert NSString:[_fullscreenOptions objectForKey:@"preferredOrientation"]]; playerLayer.autorotate = [RCTConvert BOOL:[_fullscreenOptions objectForKey:@"autorotate"]]; } playerLayer.view.frame = self.bounds; playerLayer.player = player; playerLayer.view.frame = self.bounds; Loading Loading @@ -343,7 +351,7 @@ static int const RCTVideoUnset = -1; [self addPlayerTimeObserver]; [self setFullscreen:_fullscreen]; [self setFullscreenOptions:_fullscreenOptions]; //Perform on next run loop, otherwise onVideoLoadStart is nil if (self.onVideoLoadStart) { Loading Loading @@ -1086,10 +1094,37 @@ static int const RCTVideoUnset = -1; return _fullscreenPlayerPresented; } - (void)setFullscreen:(BOOL)fullscreen { - (void)setFullscreen:(BOOL) fullscreen { _fullscreen = fullscreen; if( fullscreen && !_fullscreenPlayerPresented && _player ) NSString* enabled = _fullscreen ? @"1" : @"0"; if (!_fullscreenOptions) { [self setFullscreenOptions: @{ @"enabled": enabled, @"autorotate": @"0", @"preferredOrientation": @"default" }]; } else { [_fullscreenOptions setValue:enabled forKey:@"enabled"]; [self setFullscreenOptions:_fullscreenOptions]; } } - (void)setFullscreenOptions:(NSDictionary*) fullscreenOptions { _fullscreenOptions = fullscreenOptions; if (!_fullscreenOptions) return; BOOL fullscreenEnabled = [RCTConvert BOOL:[_fullscreenOptions objectForKey:@"enabled"]]; if( fullscreenEnabled && !_fullscreenPlayerPresented && _player ) { // Ensure player view controller is not null if( !_playerViewController ) { [self usePlayerViewController]; } Loading @@ -1115,14 +1150,14 @@ static int const RCTVideoUnset = -1; } [viewController presentViewController:_playerViewController animated:true completion:^{ _playerViewController.showsPlaybackControls = YES; _fullscreenPlayerPresented = fullscreen; _fullscreenPlayerPresented = fullscreenEnabled; if(self.onVideoFullscreenPlayerDidPresent) { self.onVideoFullscreenPlayerDidPresent(@{@"target": self.reactTag}); } }]; } } else if ( !fullscreen && _fullscreenPlayerPresented ) else if ( !fullscreenEnabled && _fullscreenPlayerPresented ) { [self videoPlayerViewControllerWillDismiss:_playerViewController]; [_presentingViewController dismissViewControllerAnimated:true completion:^{ Loading ios/Video/RCTVideoManager.m +2 −1 Changes for ios/Video/RCTVideoManager.m: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -36,7 +36,8 @@ RCT_EXPORT_VIEW_PROPERTY(ignoreSilentSwitch, NSString); RCT_EXPORT_VIEW_PROPERTY(rate, float); RCT_EXPORT_VIEW_PROPERTY(seek, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(currentTime, float); RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL); RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL); // deprecated property RCT_EXPORT_VIEW_PROPERTY(fullscreenOptions, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(progressUpdateInterval, float); /* Should support: onLoadStart, onLoad, and onError to stay consistent with Image */ RCT_EXPORT_VIEW_PROPERTY(onVideoLoadStart, RCTBubblingEventBlock); Loading ios/Video/RCTVideoPlayerViewController.h +5 −0 Changes for ios/Video/RCTVideoPlayerViewController.h: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -12,4 +12,9 @@ @interface RCTVideoPlayerViewController : AVPlayerViewController @property (nonatomic, weak) id<RCTVideoPlayerViewControllerDelegate> rctDelegate; // Optional paramters @property (nonatomic, weak) NSString* preferredOrientation; @property (nonatomic) BOOL autorotate; @end ios/Video/RCTVideoPlayerViewController.m +19 −3 Changes for ios/Video/RCTVideoPlayerViewController.m: 19 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,14 @@ @implementation RCTVideoPlayerViewController - (id)init { self = [super init]; if (self) { self.autorotate = false; } return self; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; Loading @@ -14,17 +22,25 @@ } - (BOOL)shouldAutorotate { return YES; return self.autorotate; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; return UIInterfaceOrientationMaskAll; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { if ([self.preferredOrientation.lowercaseString isEqualToString:@"landscape"]) { return UIInterfaceOrientationLandscapeLeft; } else if ([self.preferredOrientation.lowercaseString isEqualToString:@"portrait"]) { return UIInterfaceOrientationPortrait; } else { // default case UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; return orientation; } } @end Loading
Video.js +5 −0 Changes for Video.js: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -289,6 +289,11 @@ Video.propTypes = { PropTypes.object ]), fullscreen: PropTypes.bool, fullscreenOptions: PropTypes.shape({ enabled: PropTypes.bool, preferredOrientation: PropTypes.string, autorotate: PropTypes.bool }), onVideoLoadStart: PropTypes.func, onVideoLoad: PropTypes.func, onVideoBuffer: PropTypes.func, Loading
ios/Video/RCTVideo.m +41 −6 Changes for ios/Video/RCTVideo.m: 41 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ static int const RCTVideoUnset = -1; NSString * _ignoreSilentSwitch; NSString * _resizeMode; BOOL _fullscreen; NSDictionary* _fullscreenOptions; BOOL _fullscreenPlayerPresented; UIViewController * _presentingViewController; #if __has_include(<react-native-video/RCTVideoCache.h>) Loading Loading @@ -117,9 +118,16 @@ static int const RCTVideoUnset = -1; } - (AVPlayerViewController*)createPlayerViewController:(AVPlayer*)player withPlayerItem:(AVPlayerItem*)playerItem { RCTVideoPlayerViewController* playerLayer= [[RCTVideoPlayerViewController alloc] init]; playerLayer.showsPlaybackControls = YES; playerLayer.rctDelegate = self; if (_fullscreenOptions) { playerLayer.preferredOrientation = [RCTConvert NSString:[_fullscreenOptions objectForKey:@"preferredOrientation"]]; playerLayer.autorotate = [RCTConvert BOOL:[_fullscreenOptions objectForKey:@"autorotate"]]; } playerLayer.view.frame = self.bounds; playerLayer.player = player; playerLayer.view.frame = self.bounds; Loading Loading @@ -343,7 +351,7 @@ static int const RCTVideoUnset = -1; [self addPlayerTimeObserver]; [self setFullscreen:_fullscreen]; [self setFullscreenOptions:_fullscreenOptions]; //Perform on next run loop, otherwise onVideoLoadStart is nil if (self.onVideoLoadStart) { Loading Loading @@ -1086,10 +1094,37 @@ static int const RCTVideoUnset = -1; return _fullscreenPlayerPresented; } - (void)setFullscreen:(BOOL)fullscreen { - (void)setFullscreen:(BOOL) fullscreen { _fullscreen = fullscreen; if( fullscreen && !_fullscreenPlayerPresented && _player ) NSString* enabled = _fullscreen ? @"1" : @"0"; if (!_fullscreenOptions) { [self setFullscreenOptions: @{ @"enabled": enabled, @"autorotate": @"0", @"preferredOrientation": @"default" }]; } else { [_fullscreenOptions setValue:enabled forKey:@"enabled"]; [self setFullscreenOptions:_fullscreenOptions]; } } - (void)setFullscreenOptions:(NSDictionary*) fullscreenOptions { _fullscreenOptions = fullscreenOptions; if (!_fullscreenOptions) return; BOOL fullscreenEnabled = [RCTConvert BOOL:[_fullscreenOptions objectForKey:@"enabled"]]; if( fullscreenEnabled && !_fullscreenPlayerPresented && _player ) { // Ensure player view controller is not null if( !_playerViewController ) { [self usePlayerViewController]; } Loading @@ -1115,14 +1150,14 @@ static int const RCTVideoUnset = -1; } [viewController presentViewController:_playerViewController animated:true completion:^{ _playerViewController.showsPlaybackControls = YES; _fullscreenPlayerPresented = fullscreen; _fullscreenPlayerPresented = fullscreenEnabled; if(self.onVideoFullscreenPlayerDidPresent) { self.onVideoFullscreenPlayerDidPresent(@{@"target": self.reactTag}); } }]; } } else if ( !fullscreen && _fullscreenPlayerPresented ) else if ( !fullscreenEnabled && _fullscreenPlayerPresented ) { [self videoPlayerViewControllerWillDismiss:_playerViewController]; [_presentingViewController dismissViewControllerAnimated:true completion:^{ Loading
ios/Video/RCTVideoManager.m +2 −1 Changes for ios/Video/RCTVideoManager.m: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -36,7 +36,8 @@ RCT_EXPORT_VIEW_PROPERTY(ignoreSilentSwitch, NSString); RCT_EXPORT_VIEW_PROPERTY(rate, float); RCT_EXPORT_VIEW_PROPERTY(seek, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(currentTime, float); RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL); RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL); // deprecated property RCT_EXPORT_VIEW_PROPERTY(fullscreenOptions, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(progressUpdateInterval, float); /* Should support: onLoadStart, onLoad, and onError to stay consistent with Image */ RCT_EXPORT_VIEW_PROPERTY(onVideoLoadStart, RCTBubblingEventBlock); Loading
ios/Video/RCTVideoPlayerViewController.h +5 −0 Changes for ios/Video/RCTVideoPlayerViewController.h: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -12,4 +12,9 @@ @interface RCTVideoPlayerViewController : AVPlayerViewController @property (nonatomic, weak) id<RCTVideoPlayerViewControllerDelegate> rctDelegate; // Optional paramters @property (nonatomic, weak) NSString* preferredOrientation; @property (nonatomic) BOOL autorotate; @end
ios/Video/RCTVideoPlayerViewController.m +19 −3 Changes for ios/Video/RCTVideoPlayerViewController.m: 19 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,14 @@ @implementation RCTVideoPlayerViewController - (id)init { self = [super init]; if (self) { self.autorotate = false; } return self; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; Loading @@ -14,17 +22,25 @@ } - (BOOL)shouldAutorotate { return YES; return self.autorotate; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscape; return UIInterfaceOrientationMaskAll; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { if ([self.preferredOrientation.lowercaseString isEqualToString:@"landscape"]) { return UIInterfaceOrientationLandscapeLeft; } else if ([self.preferredOrientation.lowercaseString isEqualToString:@"portrait"]) { return UIInterfaceOrientationPortrait; } else { // default case UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; return orientation; } } @end