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:]:发送到解除分配的实例的消息
谁知道为什么?答案 0 :(得分:2)
在某些时候,mPlayerItem
指向的对象正在发布,但mPlayerItem
未设置为nil
。寻找你可能保留或过度释放你的玩家实例的地方。