diff --git a/README.md b/README.md index 493c2b3f..9aac6495 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,7 @@ var styles = StyleSheet.create({ ``` ### Configurable props +* [allowsExternalPlayback](#allowsexternalplayback) * [ignoreSilentSwitch](#ignoresilentswitch) * [muted](#muted) * [paused](#paused) @@ -235,6 +236,13 @@ var styles = StyleSheet.create({ * [useTextureView](#usetextureview) * [volume](#volume) +#### 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 * **"inherit" (default)** - Use the default AVPlayer behavior diff --git a/Video.js b/Video.js index c2a0a25b..5d11936c 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, selectedTextTrack: PropTypes.shape({ type: PropTypes.string.isRequired, value: PropTypes.oneOfType([ diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 30071d1b..253f48da 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -40,6 +40,7 @@ static NSString *const timedMetadata = @"timedMetadata"; BOOL _muted; BOOL _paused; BOOL _repeat; + BOOL _allowsExternalPlayback; NSDictionary * _selectedTextTrack; BOOL _playbackStalled; BOOL _playInBackground; @@ -67,6 +68,7 @@ static NSString *const timedMetadata = @"timedMetadata"; _controls = NO; _playerBufferEmpty = YES; _playInBackground = false; + _allowsExternalPlayback = YES; _playWhenInactive = false; _ignoreSilentSwitch = @"inherit"; // inherit, ignore, obey @@ -523,6 +525,12 @@ static NSString *const timedMetadata = @"timedMetadata"; _playInBackground = playInBackground; } +- (void)setAllowsExternalPlayback:(BOOL)allowsExternalPlayback +{ + _allowsExternalPlayback = allowsExternalPlayback; + _player.allowsExternalPlayback = _allowsExternalPlayback; +} + - (void)setPlayWhenInactive:(BOOL)playWhenInactive { _playWhenInactive = playWhenInactive; @@ -635,6 +643,7 @@ static NSString *const timedMetadata = @"timedMetadata"; [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 f187502f..e801447d 100644 --- a/ios/RCTVideoManager.m +++ b/ios/RCTVideoManager.m @@ -22,6 +22,7 @@ RCT_EXPORT_MODULE(); 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(selectedTextTrack, NSDictionary); RCT_EXPORT_VIEW_PROPERTY(paused, BOOL); RCT_EXPORT_VIEW_PROPERTY(muted, BOOL);