Piszę niestandardowy odtwarzacz z AVPlayera do odtwarzania wideo. Zgodnie z docs firmy Apple ustawić warstwę wideo:Przywróć odtwarzanie wideo AVPlayer po uruchomieniu aplikacji
self.player = [IPLPlayer new];
self.player.playerLayer = (AVPlayerLayer *)self.playerView.layer;
Gdzie self.playerView zwykle klasa z tych dokumentów:
@implementation PlayerView
+ (Class) layerClass {
return [AVPlayerLayer class];
}
- (AVPlayer *)player {
return [(AVPlayerLayer *)[self layer] player];
}
- (void)setPlayer:(AVPlayer *) player {
[(AVPlayerLayer *) [self layer] setPlayer:player];
}
Problemem jest: Kiedy blisko aplikacji (przycisk Start) lub ekran blok , odtwarzanie wideo zostanie zatrzymane, a gdy wznowione zostanie TYLKO odtwarzanie audio, obraz na ekranie jest nadal wyświetlany przed ekranem blokowym - jest w pełni statyczny i zmienia ramkę.
Jak wznowić odtwarzanie VIDEO po zablokowaniu ekranu?
Wydaje muszę zarejestrować powiadomień, a po aplikacji staje się warstwą aktywną resume VIDEO:
-(void)registerNotification
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(willEnterBackground)
name:UIApplicationWillResignActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didEnterForeground)
name:UIApplicationDidBecomeActiveNotification object:nil];
}
-(void)unregisterNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
-(void)willEnterBackground
{
NSLog(@"willEnterBackground");
[self.playerView willEnterBackground];
}
-(void)didEnterForeground
{
NSLog(@"didEnterForeground");
[self.playerView didEnterForeground];
}
Przepraszam, ale moje pytanie nie dotyczyło tego. – HotJard