Pause video when the app is backgrounded

This commit is contained in:
Brent Vatne 2015-06-25 15:40:46 -07:00
parent 30374adf26
commit 1f901be363
2 changed files with 27 additions and 1 deletions

View File

@ -54,11 +54,37 @@ static NSString *const statusKeyPath = @"status";
_pendingSeek = false; _pendingSeek = false;
_pendingSeekTime = 0.0f; _pendingSeekTime = 0.0f;
_lastSeekTime = 0.0f; _lastSeekTime = 0.0f;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
} }
return self; return self;
} }
#pragma mark - App lifecycle handlers
- (void)applicationWillResignActive:(NSNotification *)notification
{
if (!_paused) {
[self stopProgressTimer];
[_player pause];
}
}
- (void)applicationWillEnterForeground:(NSNotification *)notification
{
[self startProgressTimer];
[self applyModifiers];
}
#pragma mark - Progress #pragma mark - Progress
- (void)sendProgressUpdate - (void)sendProgressUpdate

View File

@ -1,6 +1,6 @@
{ {
"name": "react-native-video", "name": "react-native-video",
"version": "0.4.7", "version": "0.4.8",
"description": "A <Video /> element for react-native", "description": "A <Video /> element for react-native",
"main": "Video.ios.js", "main": "Video.ios.js",
"author": "Brent Vatne <brentvatne@gmail.com> (https://github.com/brentvatne)", "author": "Brent Vatne <brentvatne@gmail.com> (https://github.com/brentvatne)",