From c45a79a346d055a03691a3f9de640c2cfd30bde7 Mon Sep 17 00:00:00 2001 From: Tobias Hasselrot Date: Fri, 30 Oct 2015 10:34:54 +0100 Subject: [PATCH] Added playInBackground property to allow continous live streaming when opening notification center or control center --- RCTVideo.m | 9 ++++++++- RCTVideoManager.m | 1 + Video.ios.js | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/RCTVideo.m b/RCTVideo.m index 37e09e8b..11e74428 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -34,6 +34,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" BOOL _muted; BOOL _paused; BOOL _repeat; + BOOL _playInBackground; NSString * _resizeMode; } @@ -48,6 +49,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" _pendingSeek = false; _pendingSeekTime = 0.0f; _lastSeekTime = 0.0f; + _playInBackground = false; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) @@ -72,7 +74,7 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" - (void)applicationWillResignActive:(NSNotification *)notification { - if (!_paused) { + if (!_paused && !_playInBackground) { [self stopProgressTimer]; [_player setRate:0.0]; } @@ -285,6 +287,11 @@ static NSString *const playbackLikelyToKeepUpKeyPath = @"playbackLikelyToKeepUp" _playerLayer.videoGravity = mode; } +- (void)setPlayInBackground:(BOOL)playInBackground +{ + _playInBackground = playInBackground; +} + - (void)setPaused:(BOOL)paused { if (paused) { diff --git a/RCTVideoManager.m b/RCTVideoManager.m index 3f931999..02d3ea6d 100644 --- a/RCTVideoManager.m +++ b/RCTVideoManager.m @@ -39,6 +39,7 @@ RCT_EXPORT_VIEW_PROPERTY(repeat, BOOL); RCT_EXPORT_VIEW_PROPERTY(paused, BOOL); RCT_EXPORT_VIEW_PROPERTY(muted, BOOL); RCT_EXPORT_VIEW_PROPERTY(volume, float); +RCT_EXPORT_VIEW_PROPERTY(playInBackground, BOOL); RCT_EXPORT_VIEW_PROPERTY(rate, float); RCT_EXPORT_VIEW_PROPERTY(seek, float); diff --git a/Video.ios.js b/Video.ios.js index 4e716931..d9f16633 100644 --- a/Video.ios.js +++ b/Video.ios.js @@ -20,6 +20,7 @@ var Video = React.createClass({ muted: PropTypes.bool, volume: PropTypes.number, rate: PropTypes.number, + playInBackground: PropTypes.bool, onLoadStart: PropTypes.func, onLoad: PropTypes.func, onError: PropTypes.func,