我的应用使用AVPlayer播放流媒体视频。但是当它缓冲时,播放按钮会将其状态更改为暂停模式,我必须手动将其设置回播放模式。这有什么解决方案吗?
[mPlayer addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil];
[mPlayer addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];
在observeValueForKeyPath方法
中if (!mPlayer)
{
return;
}
else if (object == mPlayerItem && [path isEqualToString:@"playbackBufferEmpty"])
{
if (mPlayerItem.playbackBufferEmpty) {
//Your code here
}
}
else if (object == mPlayerItem && [path isEqualToString:@"playbackLikelyToKeepUp"])
{
if (mPlayerItem.playbackLikelyToKeepUp)
{
//Your code here
}
}