Skip to content

Commit e23f827

Browse files
authored
Merge pull request #1303 from nfb-onf/master
restored autorotate to fullscreen options
2 parents 2c391f5 + 67406b5 commit e23f827

6 files changed

+21
-1
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ var styles = StyleSheet.create({
260260
* [bufferConfig](#bufferconfig)
261261
* [controls](#controls)
262262
* [fullscreen](#fullscreen)
263+
* [fullscreenAutorotate](#fullscreenautorotate)
263264
* [fullscreenOrientation](#fullscreenorientation)
264265
* [headers](#headers)
265266
* [id](#id)
@@ -358,6 +359,11 @@ Controls whether the player enters fullscreen on play.
358359

359360
Platforms: iOS
360361

362+
#### fullscreenAutorotate
363+
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.
364+
365+
Platforms: iOS
366+
361367
#### fullscreenOrientation
362368

363369
* **all (default)** -

Video.js

+1
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ Video.propTypes = {
354354
controls: PropTypes.bool,
355355
audioOnly: PropTypes.bool,
356356
currentTime: PropTypes.number,
357+
fullscreenAutorotate: PropTypes.bool,
357358
fullscreenOrientation: PropTypes.oneOf(['all','landscape','portrait']),
358359
progressUpdateInterval: PropTypes.number,
359360
useTextureView: PropTypes.bool,

ios/Video/RCTVideo.m

+10
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ @implementation RCTVideo
6464
NSString * _ignoreSilentSwitch;
6565
NSString * _resizeMode;
6666
BOOL _fullscreen;
67+
BOOL _fullscreenAutorotate;
6768
NSString * _fullscreenOrientation;
6869
BOOL _fullscreenPlayerPresented;
6970
UIViewController * _presentingViewController;
@@ -83,6 +84,7 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
8384
_rate = 1.0;
8485
_volume = 1.0;
8586
_resizeMode = @"AVLayerVideoGravityResizeAspectFill";
87+
_fullscreenAutorotate = YES;
8688
_fullscreenOrientation = @"all";
8789
_pendingSeek = false;
8890
_pendingSeekTime = 0.0f;
@@ -1136,6 +1138,7 @@ - (void)setFullscreen:(BOOL) fullscreen {
11361138
[viewController presentViewController:_playerViewController animated:true completion:^{
11371139
_playerViewController.showsPlaybackControls = YES;
11381140
_fullscreenPlayerPresented = fullscreen;
1141+
_playerViewController.autorotate = _fullscreenAutorotate;
11391142
if(self.onVideoFullscreenPlayerDidPresent) {
11401143
self.onVideoFullscreenPlayerDidPresent(@{@"target": self.reactTag});
11411144
}
@@ -1151,6 +1154,13 @@ - (void)setFullscreen:(BOOL) fullscreen {
11511154
}
11521155
}
11531156

1157+
- (void)setFullscreenAutorotate:(BOOL)autorotate {
1158+
_fullscreenAutorotate = autorotate;
1159+
if (_fullscreenPlayerPresented) {
1160+
_playerViewController.autorotate = autorotate;
1161+
}
1162+
}
1163+
11541164
- (void)setFullscreenOrientation:(NSString *)orientation {
11551165
_fullscreenOrientation = orientation;
11561166
if (_fullscreenPlayerPresented) {

ios/Video/RCTVideoManager.m

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ - (dispatch_queue_t)methodQueue
3737
RCT_EXPORT_VIEW_PROPERTY(seek, NSDictionary);
3838
RCT_EXPORT_VIEW_PROPERTY(currentTime, float);
3939
RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL);
40+
RCT_EXPORT_VIEW_PROPERTY(fullscreenAutorotate, BOOL);
4041
RCT_EXPORT_VIEW_PROPERTY(fullscreenOrientation, NSString);
4142
RCT_EXPORT_VIEW_PROPERTY(progressUpdateInterval, float);
4243
/* Should support: onLoadStart, onLoad, and onError to stay consistent with Image */

ios/Video/RCTVideoPlayerViewController.h

+1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515

1616
// Optional paramters
1717
@property (nonatomic, weak) NSString* preferredOrientation;
18+
@property (nonatomic) BOOL autorotate;
1819

1920
@end

ios/Video/RCTVideoPlayerViewController.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ @interface RCTVideoPlayerViewController ()
77
@implementation RCTVideoPlayerViewController
88

99
- (BOOL)shouldAutorotate {
10-
if (self.preferredOrientation.lowercaseString == nil || [self.preferredOrientation.lowercaseString isEqualToString:@"all"])
10+
11+
if (self.autorotate || self.preferredOrientation.lowercaseString == nil || [self.preferredOrientation.lowercaseString isEqualToString:@"all"])
1112
return YES;
1213

1314
return NO;

0 commit comments

Comments
 (0)