Skip to content

Commit

Permalink
Merge pull request #1303 from nfb-onf/master
Browse files Browse the repository at this point in the history
restored autorotate to fullscreen options
  • Loading branch information
cobarx authored Nov 14, 2018
2 parents 2c391f5 + 67406b5 commit e23f827
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
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

0 comments on commit e23f827

Please sign in to comment.