mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-02-15 07:19:57 +00:00
Automatically resume ASVideoNode after returning from background (#13)
This commit is contained in:
committed by
Adlai Holler
parent
b1e1bfda20
commit
471f02daa7
@@ -108,6 +108,9 @@ static NSString * const kRate = @"rate";
|
||||
[self addTarget:self action:@selector(tapped) forControlEvents:ASControlNodeEventTouchUpInside];
|
||||
_lastPlaybackTime = kCMTimeZero;
|
||||
|
||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
[notificationCenter addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -714,6 +717,13 @@ static NSString * const kRate = @"rate";
|
||||
|
||||
#pragma mark - Playback observers
|
||||
|
||||
- (void)applicationDidBecomeActive:(NSNotification *)notification
|
||||
{
|
||||
if (self.shouldBePlaying && self.isVisible) {
|
||||
[self play];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didPlayToEnd:(NSNotification *)notification
|
||||
{
|
||||
self.playerState = ASVideoNodePlayerStateFinished;
|
||||
@@ -825,6 +835,9 @@ static NSString * const kRate = @"rate";
|
||||
_timeObserver = nil;
|
||||
[self removePlayerItemObservers:_currentPlayerItem];
|
||||
[self removePlayerObservers:_player];
|
||||
|
||||
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||
[notificationCenter removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user