Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restored autorotate to fullscreen options #1303

Merged
merged 1 commit into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ var styles = StyleSheet.create({
* [bufferConfig](#bufferconfig)
* [controls](#controls)
* [fullscreen](#fullscreen)
* [fullscreenAutorotate](#fullscreenautorotate)
* [fullscreenOrientation](#fullscreenorientation)
* [headers](#headers)
* [id](#id)
Expand Down Expand Up @@ -358,6 +359,11 @@ Controls whether the player enters fullscreen on play.

Platforms: iOS

#### fullscreenAutorotate
If a preferred [fullscreenOrientation](#fullscreenorientation) is set, causes the video to rotate to that orientation but permits rotation of the screen to orientation held by user. Defaults to TRUE.

Platforms: iOS

#### fullscreenOrientation

* **all (default)** -
Expand Down
1 change: 1 addition & 0 deletions Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ Video.propTypes = {
controls: PropTypes.bool,
audioOnly: PropTypes.bool,
currentTime: PropTypes.number,
fullscreenAutorotate: PropTypes.bool,
fullscreenOrientation: PropTypes.oneOf(['all','landscape','portrait']),
progressUpdateInterval: PropTypes.number,
useTextureView: PropTypes.bool,
Expand Down
10 changes: 10 additions & 0 deletions ios/Video/RCTVideo.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ @implementation RCTVideo
NSString * _ignoreSilentSwitch;
NSString * _resizeMode;
BOOL _fullscreen;
BOOL _fullscreenAutorotate;
NSString * _fullscreenOrientation;
BOOL _fullscreenPlayerPresented;
UIViewController * _presentingViewController;
Expand All @@ -83,6 +84,7 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
_rate = 1.0;
_volume = 1.0;
_resizeMode = @"AVLayerVideoGravityResizeAspectFill";
_fullscreenAutorotate = YES;
_fullscreenOrientation = @"all";
_pendingSeek = false;
_pendingSeekTime = 0.0f;
Expand Down Expand Up @@ -1136,6 +1138,7 @@ - (void)setFullscreen:(BOOL) fullscreen {
[viewController presentViewController:_playerViewController animated:true completion:^{
_playerViewController.showsPlaybackControls = YES;
_fullscreenPlayerPresented = fullscreen;
_playerViewController.autorotate = _fullscreenAutorotate;
if(self.onVideoFullscreenPlayerDidPresent) {
self.onVideoFullscreenPlayerDidPresent(@{@"target": self.reactTag});
}
Expand All @@ -1151,6 +1154,13 @@ - (void)setFullscreen:(BOOL) fullscreen {
}
}

- (void)setFullscreenAutorotate:(BOOL)autorotate {
_fullscreenAutorotate = autorotate;
if (_fullscreenPlayerPresented) {
_playerViewController.autorotate = autorotate;
}
}

- (void)setFullscreenOrientation:(NSString *)orientation {
_fullscreenOrientation = orientation;
if (_fullscreenPlayerPresented) {
Expand Down
1 change: 1 addition & 0 deletions ios/Video/RCTVideoManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ - (dispatch_queue_t)methodQueue
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 */
Expand Down
1 change: 1 addition & 0 deletions ios/Video/RCTVideoPlayerViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@

// Optional paramters
@property (nonatomic, weak) NSString* preferredOrientation;
@property (nonatomic) BOOL autorotate;

@end
3 changes: 2 additions & 1 deletion ios/Video/RCTVideoPlayerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ @interface RCTVideoPlayerViewController ()
@implementation RCTVideoPlayerViewController

- (BOOL)shouldAutorotate {
if (self.preferredOrientation.lowercaseString == nil || [self.preferredOrientation.lowercaseString isEqualToString:@"all"])

if (self.autorotate || self.preferredOrientation.lowercaseString == nil || [self.preferredOrientation.lowercaseString isEqualToString:@"all"])
return YES;

return NO;
Expand Down