【发布时间】:2016-01-05 14:13:47
【问题描述】:
所以我试图在后台更新 MPNowPlayingInfoCenter 并且 AVQueuePlayer 中的轨道发生变化。
在前台很容易在
- (id) init{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinish) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];
player = [[AVQueuePlayer alloc]init];
player.actionAtItemEnd = AVPlayerActionAtItemEndPause;
}
-(void)didFinish{
[[NSNotificationCenter defaultCenter] removeObserver:self];
// Magic goes here
//[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:nowPlaying];
[player advanceToNextItem];
[player play];
}
在后台但是没有 AVPlayerActionAtItemEndAdvance 它不会转到下一个,并且 AVPlayerActionAtItemEndAdvance 永远不会在后台调用 didFinish
- (id) init{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinish) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];
player = [[AVQueuePlayer alloc]init];
player.actionAtItemEnd = AVPlayerActionAtItemEndAdvance;
}
-(void)didFinish{ //never called
[[NSNotificationCenter defaultCenter] removeObserver:self];
// Magic goes here
//[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:nowPlaying];
//play is not needed in this case
}
谢谢!
【问题讨论】:
标签: ios objective-c iphone