Pause video when the app is backgrounded
This commit is contained in:
parent
30374adf26
commit
1f901be363
26
RCTVideo.m
26
RCTVideo.m
@ -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
|
||||||
|
@ -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)",
|
||||||
|
Loading…
Reference in New Issue
Block a user