From e79e447375f26027510f3aaa84b2f916e2c45b3c Mon Sep 17 00:00:00 2001 From: LeoGeng Date: Wed, 6 Jun 2018 09:40:12 +0800 Subject: [PATCH] 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 25beee6e..d80ba934 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; BOOL _playbackStalled; BOOL _playInBackground; BOOL _playWhenInactive; @@ -66,6 +67,7 @@ static NSString *const timedMetadata = @"timedMetadata"; _controls = NO; _playerBufferEmpty = YES; _playInBackground = false; + _allowsExternalPlayback = YES; _playWhenInactive = false; _ignoreSilentSwitch = @"inherit"; // inherit, ignore, obey @@ -522,6 +524,12 @@ static NSString *const timedMetadata = @"timedMetadata"; _playInBackground = playInBackground; } +- (void)setAllowsExternalPlayback:(BOOL)allowsExternalPlayback +{ + _allowsExternalPlayback = allowsExternalPlayback; + _player.allowsExternalPlayback = _allowsExternalPlayback; +} + - (void)setPlayWhenInactive:(BOOL)playWhenInactive { _playWhenInactive = playWhenInactive; @@ -633,6 +641,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 c1edb9b7..4fa1a1f1 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(paused, BOOL); RCT_EXPORT_VIEW_PROPERTY(muted, BOOL); RCT_EXPORT_VIEW_PROPERTY(controls, BOOL);