我使用AVPlayer来流跟踪。我正在尝试处理所有错误,例如网络不可用或流不可用,但是我找到了处理此类错误的任何处理程序。
我已经为avplayer的状态添加了一个KVO。
[self.player addObserver:self forKeyPath:@"status" options:0 context:nil];
但是,即使流不存在(例如,错误的URL),状态也会切换到AVPlayerStatusReadyToPlay。
编辑
解决方案是使用AVPLayerItems并使用AVQueuPlayer。另一个问题是我在每个轨道上都重新分配了该播放器。
也将KVO添加到AVPlayerItem而不是使用NSKeyValueObservingOptionNew的AVPlayer。
[playerItem addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:NULL];
[self.player replaceCurrentItemWithPlayerItem:playerItem];
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句