From adf63e5fa081b0eede53cde3467e7d0b334f85f2 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 12 Oct 2018 16:59:36 +0100 Subject: [PATCH 1/4] Make seek() throw an exception when using NaN value --- Video.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Video.js b/Video.js index 4529dd44..b191dae1 100644 --- a/Video.js +++ b/Video.js @@ -51,6 +51,8 @@ export default class Video extends Component { } seek = (time, tolerance = 100) => { + if (isNaN(time)) throw new Error('Specified time is not a number'); + if (Platform.OS === 'ios') { this.setNativeProps({ seek: { From 67406b5e7b0255fdec316cb792d744e263d8f4b1 Mon Sep 17 00:00:00 2001 From: Ash Mishra Date: Thu, 18 Oct 2018 15:21:46 -0700 Subject: [PATCH 2/4] restored autorotate to fullscreen options --- README.md | 6 ++++++ Video.js | 1 + ios/Video/RCTVideo.m | 10 ++++++++++ ios/Video/RCTVideoManager.m | 1 + ios/Video/RCTVideoPlayerViewController.h | 1 + ios/Video/RCTVideoPlayerViewController.m | 3 ++- 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f653dd86..6198c56f 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,7 @@ var styles = StyleSheet.create({ * [bufferConfig](#bufferconfig) * [controls](#controls) * [fullscreen](#fullscreen) +* [fullscreenAutorotate](#fullscreenautorotate) * [fullscreenOrientation](#fullscreenorientation) * [headers](#headers) * [id](#id) @@ -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)** - diff --git a/Video.js b/Video.js index e430e419..cd39457d 100644 --- a/Video.js +++ b/Video.js @@ -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, diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index a165d5c8..e0a5ac2b 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -64,6 +64,7 @@ static int const RCTVideoUnset = -1; NSString * _ignoreSilentSwitch; NSString * _resizeMode; BOOL _fullscreen; + BOOL _fullscreenAutorotate; NSString * _fullscreenOrientation; BOOL _fullscreenPlayerPresented; UIViewController * _presentingViewController; @@ -83,6 +84,7 @@ static int const RCTVideoUnset = -1; _rate = 1.0; _volume = 1.0; _resizeMode = @"AVLayerVideoGravityResizeAspectFill"; + _fullscreenAutorotate = YES; _fullscreenOrientation = @"all"; _pendingSeek = false; _pendingSeekTime = 0.0f; @@ -1136,6 +1138,7 @@ static int const RCTVideoUnset = -1; [viewController presentViewController:_playerViewController animated:true completion:^{ _playerViewController.showsPlaybackControls = YES; _fullscreenPlayerPresented = fullscreen; + _playerViewController.autorotate = _fullscreenAutorotate; if(self.onVideoFullscreenPlayerDidPresent) { self.onVideoFullscreenPlayerDidPresent(@{@"target": self.reactTag}); } @@ -1151,6 +1154,13 @@ static int const RCTVideoUnset = -1; } } +- (void)setFullscreenAutorotate:(BOOL)autorotate { + _fullscreenAutorotate = autorotate; + if (_fullscreenPlayerPresented) { + _playerViewController.autorotate = autorotate; + } +} + - (void)setFullscreenOrientation:(NSString *)orientation { _fullscreenOrientation = orientation; if (_fullscreenPlayerPresented) { diff --git a/ios/Video/RCTVideoManager.m b/ios/Video/RCTVideoManager.m index aa3c4670..ce699a18 100644 --- a/ios/Video/RCTVideoManager.m +++ b/ios/Video/RCTVideoManager.m @@ -37,6 +37,7 @@ 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 */ diff --git a/ios/Video/RCTVideoPlayerViewController.h b/ios/Video/RCTVideoPlayerViewController.h index 99b1349b..ed9ebdde 100644 --- a/ios/Video/RCTVideoPlayerViewController.h +++ b/ios/Video/RCTVideoPlayerViewController.h @@ -15,5 +15,6 @@ // Optional paramters @property (nonatomic, weak) NSString* preferredOrientation; +@property (nonatomic) BOOL autorotate; @end diff --git a/ios/Video/RCTVideoPlayerViewController.m b/ios/Video/RCTVideoPlayerViewController.m index e9550db5..548a06ce 100644 --- a/ios/Video/RCTVideoPlayerViewController.m +++ b/ios/Video/RCTVideoPlayerViewController.m @@ -7,7 +7,8 @@ @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; From dece8a2ca17bc8d311e4c2fccc28be749d252fde Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Tue, 13 Nov 2018 23:04:03 -0800 Subject: [PATCH 3/4] Re-add fullscreenAutorotate prop --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e84036a..e4f3d933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ * Add fullscreenOrientation option for iOS [#1215](https://github.com/react-native-community/react-native-video/pull/1215) * Update to ExoPlayer 2.9.0 [#1285](https://github.com/react-native-community/react-native-video/pull/1285) * Switch useTextureView to default to `true` [#1286](https://github.com/react-native-community/react-native-video/pull/1286) +* Re-add fullscreenAutorotate prop [#1303](https://github.com/react-native-community/react-native-video/pull/1303) ### Version 3.2.0 * Basic fullscreen support for Android MediaPlayer [#1138](https://github.com/react-native-community/react-native-video/pull/1138) From 30c30ec5758211032ee315a776be293519cff916 Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Tue, 13 Nov 2018 23:12:08 -0800 Subject: [PATCH 4/4] Make seek() throw an exception when using NaN value --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4f3d933..6cade30c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * Update to ExoPlayer 2.9.0 [#1285](https://github.com/react-native-community/react-native-video/pull/1285) * Switch useTextureView to default to `true` [#1286](https://github.com/react-native-community/react-native-video/pull/1286) * Re-add fullscreenAutorotate prop [#1303](https://github.com/react-native-community/react-native-video/pull/1303) +* Make seek throw a useful error for NaN values [#1283](https://github.com/react-native-community/react-native-video/pull/1283) ### Version 3.2.0 * Basic fullscreen support for Android MediaPlayer [#1138](https://github.com/react-native-community/react-native-video/pull/1138)