if (mPlayerItem){
[mPlayerItem removeObserver:self forKeyPath:kStatusKey];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:AVPlayerItemDidPlayToEndTimeNotification
object:mPlayerItem];
}
//create AVPlayerItem
NSURL *url = [self getUrlWithROAudio:audioFile];
mPlayerItem = [AVPlayerItem playerItemWithURL:url];
[mPlayerItem addObserver:self
forKeyPath:kStatusKey
options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
context:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:mPlayerItem];
当我创建一个新的 AVPlayerItem 时,我将检查最后一个是否存在,并且 removeObserver 但我得到了
-[AVPlayerItem removeObserver:forKeyPath:]: message sent to deallocated instance
有谁知道为什么?