From e79e447375f26027510f3aaa84b2f916e2c45b3c Mon Sep 17 00:00:00 2001 From: LeoGeng Date: Wed, 6 Jun 2018 09:40:12 +0800 Subject: [PATCH 1/5] Add allowsExternalPlayback property to control external playback --- ios/RCTVideo.m | 9 +++++++++ ios/RCTVideoManager.m | 1 + 2 files changed, 10 insertions(+) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 25beee6efe..d80ba9345f 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -40,6 +40,7 @@ @implementation RCTVideo BOOL _muted; BOOL _paused; BOOL _repeat; + BOOL _allowsExternalPlayback; BOOL _playbackStalled; BOOL _playInBackground; BOOL _playWhenInactive; @@ -66,6 +67,7 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher _controls = NO; _playerBufferEmpty = YES; _playInBackground = false; + _allowsExternalPlayback = YES; _playWhenInactive = false; _ignoreSilentSwitch = @"inherit"; // inherit, ignore, obey @@ -522,6 +524,12 @@ - (void)setPlayInBackground:(BOOL)playInBackground _playInBackground = playInBackground; } +- (void)setAllowsExternalPlayback:(BOOL)allowsExternalPlayback +{ + _allowsExternalPlayback = allowsExternalPlayback; + _player.allowsExternalPlayback = _allowsExternalPlayback; +} + - (void)setPlayWhenInactive:(BOOL)playWhenInactive { _playWhenInactive = playWhenInactive; @@ -633,6 +641,7 @@ - (void)applyModifiers [self setRepeat:_repeat]; [self setPaused:_paused]; [self setControls:_controls]; + [self setAllowsExternalPlayback:_allowsExternalPlayback]; } - (void)setRepeat:(BOOL)repeat { diff --git a/ios/RCTVideoManager.m b/ios/RCTVideoManager.m index c1edb9b782..4fa1a1f1a0 100644 --- a/ios/RCTVideoManager.m +++ b/ios/RCTVideoManager.m @@ -22,6 +22,7 @@ - (dispatch_queue_t)methodQueue RCT_EXPORT_VIEW_PROPERTY(src, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(resizeMode, NSString); RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL); +RCT_EXPORT_VIEW_PROPERTY(allowsExternalPlayback, BOOL); RCT_EXPORT_VIEW_PROPERTY(paused, BOOL); RCT_EXPORT_VIEW_PROPERTY(muted, BOOL); RCT_EXPORT_VIEW_PROPERTY(controls, BOOL); From b83fda983898e7a5dbdd8e585bdaf6a2400a16ff Mon Sep 17 00:00:00 2001 From: LeoGeng Date: Wed, 6 Jun 2018 10:22:19 +0800 Subject: [PATCH 2/5] Add allowsExternalPlayback to video for ios --- Video.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Video.js b/Video.js index aced6e55d2..80187e95e6 100644 --- a/Video.js +++ b/Video.js @@ -274,6 +274,7 @@ Video.propTypes = { poster: PropTypes.string, posterResizeMode: Image.propTypes.resizeMode, repeat: PropTypes.bool, + allowsExternalPlayback: PropTypes.bool, paused: PropTypes.bool, muted: PropTypes.bool, volume: PropTypes.number, From 6f5211f2c4250afc156d2a310ec72f326e1d6a80 Mon Sep 17 00:00:00 2001 From: genglei01 Date: Mon, 11 Jun 2018 00:04:13 +0800 Subject: [PATCH 3/5] remove indentation remove indentation --- ios/RCTVideo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 17afef687c..253f48daeb 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -68,7 +68,7 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher _controls = NO; _playerBufferEmpty = YES; _playInBackground = false; - _allowsExternalPlayback = YES; + _allowsExternalPlayback = YES; _playWhenInactive = false; _ignoreSilentSwitch = @"inherit"; // inherit, ignore, obey From 187158be34dbe2f3f19bebc1833268990887febf Mon Sep 17 00:00:00 2001 From: LeoGeng Date: Mon, 11 Jun 2018 00:31:22 +0800 Subject: [PATCH 4/5] add an entry in the README for allowsExternalPlayback property --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b1ee113e15..936504fbea 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,7 @@ var styles = StyleSheet.create({ * [resizeMode](#resizemode) * [selectedTextTrack](#selectedtexttrack) * [volume](#volume) +* [allowsExternalPlayback](#allowsExternalPlayback) #### ignoreSilentSwitch Controls the iOS silent switch behavior @@ -345,6 +346,12 @@ Adjust the volume. Platforms: all +#### allowsExternalPlayback +A Boolean value that indicates whether the player allows switching to external playback mode. +* **true (default)** - allow switching to external playback mode +* **false** - Don't allow switching to external playback mode +Platforms: iOS + ### Additional props To see the full list of available props, you can check the [propTypes](https://github.com/react-native-community/react-native-video/blob/master/Video.js#L246) of the Video.js component. From 36dffa694cb9e6907f69b89b964332fcf6397fec Mon Sep 17 00:00:00 2001 From: Hampton Maxwell Date: Sun, 10 Jun 2018 10:48:32 -0700 Subject: [PATCH 5/5] Reorder allowsExternalPlayback alphabetically --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 936504fbea..ee5d6d8e1b 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,7 @@ var styles = StyleSheet.create({ ``` ### Configurable props +* [allowsExternalPlayback](#allowsexternalplayback) * [ignoreSilentSwitch](#ignoresilentswitch) * [muted](#muted) * [paused](#paused) @@ -232,7 +233,13 @@ var styles = StyleSheet.create({ * [resizeMode](#resizemode) * [selectedTextTrack](#selectedtexttrack) * [volume](#volume) -* [allowsExternalPlayback](#allowsExternalPlayback) + +#### allowsExternalPlayback +Indicates whether the player allows switching to external playback mode such as AirPlay or HDMI. +* **true (default)** - allow switching to external playback mode +* **false** - Don't allow switching to external playback mode + +Platforms: iOS #### ignoreSilentSwitch Controls the iOS silent switch behavior @@ -346,12 +353,6 @@ Adjust the volume. Platforms: all -#### allowsExternalPlayback -A Boolean value that indicates whether the player allows switching to external playback mode. -* **true (default)** - allow switching to external playback mode -* **false** - Don't allow switching to external playback mode -Platforms: iOS - ### Additional props To see the full list of available props, you can check the [propTypes](https://github.com/react-native-community/react-native-video/blob/master/Video.js#L246) of the Video.js component.