From 9be4dc45dddbbd76f98a1d9361506fbe2bd59b8c Mon Sep 17 00:00:00 2001 From: Bennett Kolasinski Date: Mon, 9 Apr 2018 14:30:27 -0700 Subject: [PATCH] expose allowsExternalPlayback (iOS only) --- Video.js | 1 + ios/RCTVideo.m | 8 ++++++++ ios/RCTVideoManager.m | 2 ++ 3 files changed, 11 insertions(+) diff --git a/Video.js b/Video.js index feb79861d9..255fbe879d 100644 --- a/Video.js +++ b/Video.js @@ -280,6 +280,7 @@ Video.propTypes = { playInBackground: PropTypes.bool, playWhenInactive: PropTypes.bool, ignoreSilentSwitch: PropTypes.oneOf(['ignore', 'obey']), + allowsExternalPlayback: PropTypes.bool, disableFocus: PropTypes.bool, controls: PropTypes.bool, currentTime: PropTypes.number, diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index ffc4acd825..5aac1f8176 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -46,6 +46,7 @@ @implementation RCTVideo NSString * _ignoreSilentSwitch; NSString * _resizeMode; BOOL _fullscreenPlayerPresented; + BOOL _allowsExternalPlayback; UIViewController * _presentingViewController; } @@ -68,6 +69,7 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher _playInBackground = false; _playWhenInactive = false; _ignoreSilentSwitch = @"inherit"; // inherit, ignore, obey + _allowsExternalPlayback = YES; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) @@ -540,6 +542,12 @@ - (void)setPaused:(BOOL)paused _paused = paused; } +- (void)setAllowsExternalPlayback:(BOOL)allowsExternalPlayback +{ + _allowsExternalPlayback = allowsExternalPlayback; + [_player setAllowsExternalPlayback:allowsExternalPlayback]; +} + - (float)getCurrentTime { return _playerItem != NULL ? CMTimeGetSeconds(_playerItem.currentTime) : 0; diff --git a/ios/RCTVideoManager.m b/ios/RCTVideoManager.m index a5cf85e0b6..f25da9738c 100644 --- a/ios/RCTVideoManager.m +++ b/ios/RCTVideoManager.m @@ -34,6 +34,8 @@ - (dispatch_queue_t)methodQueue RCT_EXPORT_VIEW_PROPERTY(currentTime, float); RCT_EXPORT_VIEW_PROPERTY(fullscreen, BOOL); RCT_EXPORT_VIEW_PROPERTY(progressUpdateInterval, float); +RCT_EXPORT_VIEW_PROPERTY(allowsExternalPlayback, BOOL); + /* Should support: onLoadStart, onLoad, and onError to stay consistent with Image */ RCT_EXPORT_VIEW_PROPERTY(onVideoLoadStart, RCTBubblingEventBlock); RCT_EXPORT_VIEW_PROPERTY(onVideoLoad, RCTBubblingEventBlock);