AVPlayerItem *currentItem = self.player.currentItem;[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:currentItem]; 我有上面的通知设置
AVPlayerItem *currentItem = self.player.currentItem; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:currentItem];
我有上面的通知设置.当我使用iOS 7运行测试时,它被称为奇妙的,但是,我从未使用iOS 8运行我的应用程序.
通过将一个观察者注册到速率密钥路径来解决它.[self.player addObserver:self forKeyPath:@"rate" options:0 context:nil]; - (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context { if (self.player.rate == 0.0) { CMTime time = self.player.currentTime; if (time >= duration) { //song reached end } }