Commit 4b327143 authored by Gleb Pinigin's avatar Gleb Pinigin Committed by Felix Paul Kühne

VLCMediaPlayer: implement native player behavior on iOS

Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent 9545aeca
......@@ -95,6 +95,7 @@ extern NSString * VLCMediaPlayerStateToString(VLCMediaPlayerState state);
float position; //< The position of the media being played
id drawable; //< The drawable associated to this media player
VLCAudio *audio;
BOOL shouldResumePlaying; //< resume playing on iOS
}
#if !TARGET_OS_IPHONE
......
......@@ -840,8 +840,13 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
[self registerObservers];
#if TARGET_OS_IPHONE
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification object:nil];
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(applicationWillResignActive:)
name:UIApplicationWillResignActiveNotification object:nil];
[center addObserver:self selector:@selector(applicationDidBecomeActive:)
name:UIApplicationDidBecomeActiveNotification object:nil];
[center addObserver:self selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification object:nil];
#endif
[self setDrawable:aDrawable];
......@@ -884,8 +889,22 @@ static const VLCMediaPlayerState libvlc_to_local_state[] =
#if TARGET_OS_IPHONE
- (void)applicationWillResignActive:(NSNotification *)notification
{
shouldResumePlaying = YES;
[self pause];
}
- (void)applicationDidEnterBackground:(NSNotification *)notification
{
shouldResumePlaying = NO;
}
- (void)applicationDidBecomeActive:(NSNotification *)notification
{
if (shouldResumePlaying) {
shouldResumePlaying = NO;
[self play];
}
}
#endif
- (void)mediaPlayerTimeChanged:(NSNumber *)newTime
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment