Removed autoRotate from codebase; added TV_OS target check for

orientation; added tvOS target to examples/basic/ios project
This commit is contained in:
Ash Mishra
2018-10-09 16:01:41 -07:00
parent 0646dca071
commit bbf37ed5cb
13 changed files with 331 additions and 305 deletions

View File

@@ -1,9 +1,9 @@
#import <React/RCTView.h>
#import <AVFoundation/AVFoundation.h>
#import "AVKit/AVKit.h"
#import "UIView+FindUIViewController.h"
#import "RCTVideoPlayerViewController.h"
#import "RCTVideoPlayerViewControllerDelegate.h"
#import <React/RCTComponent.h>
#if __has_include(<react-native-video/RCTVideoCache.h>)
#import <react-native-video/RCTVideoCache.h>

View File

@@ -64,7 +64,6 @@ static int const RCTVideoUnset = -1;
NSString * _ignoreSilentSwitch;
NSString * _resizeMode;
BOOL _fullscreen;
BOOL _fullscreenAutorotate;
NSString * _fullscreenOrientation;
BOOL _fullscreenPlayerPresented;
UIViewController * _presentingViewController;
@@ -84,8 +83,7 @@ static int const RCTVideoUnset = -1;
_rate = 1.0;
_volume = 1.0;
_resizeMode = @"AVLayerVideoGravityResizeAspectFill";
_fullscreenAutorotate = YES;
_fullscreenOrientation = @"default";
_fullscreenOrientation = @"all";
_pendingSeek = false;
_pendingSeekTime = 0.0f;
_lastSeekTime = 0.0f;
@@ -128,7 +126,6 @@ static int const RCTVideoUnset = -1;
RCTVideoPlayerViewController* viewController = [[RCTVideoPlayerViewController alloc] init];
viewController.showsPlaybackControls = YES;
viewController.rctDelegate = self;
viewController.autorotate = _fullscreenAutorotate;
viewController.preferredOrientation = _fullscreenOrientation;
viewController.view.frame = self.bounds;
@@ -1109,7 +1106,7 @@ static int const RCTVideoUnset = -1;
}
- (void)setFullscreen:(BOOL) fullscreen {
if( fullscreen && !_fullscreenPlayerPresented )
if( fullscreen && !_fullscreenPlayerPresented && _player )
{
// Ensure player view controller is not null
if( !_playerViewController )
@@ -1154,13 +1151,6 @@ static int const RCTVideoUnset = -1;
}
}
- (void)setFullscreenAutorotate:(BOOL)autorotate {
_fullscreenAutorotate = autorotate;
if (_fullscreenPlayerPresented) {
_playerViewController.autorotate = autorotate;
}
}
- (void)setFullscreenOrientation:(NSString *)orientation {
_fullscreenOrientation = orientation;
if (_fullscreenPlayerPresented) {

View File

@@ -37,7 +37,6 @@ 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(fullscreenAutorotate, BOOL);
RCT_EXPORT_VIEW_PROPERTY(fullscreenOrientation, NSString);
RCT_EXPORT_VIEW_PROPERTY(progressUpdateInterval, float);
/* Should support: onLoadStart, onLoad, and onError to stay consistent with Image */

View File

@@ -15,6 +15,5 @@
// Optional paramters
@property (nonatomic, weak) NSString* preferredOrientation;
@property (nonatomic) BOOL autorotate;
@end

View File

@@ -6,12 +6,11 @@
@implementation RCTVideoPlayerViewController
- (id)init {
self = [super init];
if (self) {
self.autorotate = true; // autorotate should be true by default
}
return self;
- (BOOL)shouldAutorotate {
if (self.preferredOrientation.lowercaseString == nil || [self.preferredOrientation.lowercaseString isEqualToString:@"all"])
return YES;
return NO;
}
- (void)viewDidDisappear:(BOOL)animated
@@ -21,18 +20,8 @@
[_rctDelegate videoPlayerViewControllerDidDismiss:self];
}
- (BOOL)shouldAutorotate {
return self.autorotate;
}
#if !TARGET_OS_TV
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
if ([self.preferredOrientation.lowercaseString isEqualToString:@"landscape"]) {
return UIInterfaceOrientationMaskLandscape;
}
else if ([self.preferredOrientation.lowercaseString isEqualToString:@"portrait"]) {
return UIInterfaceOrientationMaskPortrait;
}
return UIInterfaceOrientationMaskAll;
}
@@ -48,5 +37,6 @@
return orientation;
}
}
#endif
@end