diff --git a/RCTVideo.m b/RCTVideo.m index d6bf41b4..28b25bb9 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -63,6 +63,11 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; name:UIApplicationWillResignActiveNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(applicationDidEnterBackground:) + name:UIApplicationDidEnterBackgroundNotification + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification @@ -119,15 +124,20 @@ static NSString *const playbackBufferEmptyKeyPath = @"playbackBufferEmpty"; - (void)applicationWillResignActive:(NSNotification *)notification { - if (_playInBackground) { - // Needed to play sound in background. See https://developer.apple.com/library/ios/qa/qa1668/_index.html - [_playerLayer setPlayer:nil]; - } else if (!_paused) { + if (!_paused && !_playInBackground) { [_player pause]; [_player setRate:0.0]; } } +- (void)applicationDidEnterBackground:(NSNotification *)notification +{ + if (_playInBackground) { + // Needed to play sound in background. See https://developer.apple.com/library/ios/qa/qa1668/_index.html + [_playerLayer setPlayer:nil]; + } +} + - (void)applicationWillEnterForeground:(NSNotification *)notification { [self applyModifiers];