作为标题,我正在尝试使用实例在iOS和OS X上直播互联网广播。AVPlayer
一切都按预期进行,只需一个简单的player = [AVPlayer playerWithURL:URL];
在使用该应用程序时,我注意到流仅在 15 分钟后停止,给予或接受一些。问题是没有注意到。
[player addObserver:self forKeyPath:@"status" options:0 context:nil];
[player addObserver:self forKeyPath:@"rate" options:0 context:nil];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if (object == player) {
if ([keyPath isEqualToString:@"status"]) {
NSLog(@"status -> %ld", player.status);
}
if ([keyPath isEqualToString:@"rate"]) {
NSLog(@"rate -> %f", player.rate);
}
}
}
1
即使音频停止播放,两个值都切换到但永远不会再次切换。在 iOS 上,右上角的播放图标消失了,但由于 player.rate 值没有改变,应用程序仍然认为正在播放音频。
首先我以为是流,所以我尝试了 5by5 和 twit 的其他流,同样的事情发生了。
然后我以为是我的连接,所以在流开始后,我关闭了我的连接,大约一分钟后,AVPlayerItemDidPlayToEndTimeNotification
我观察到被解雇了。
花了一段时间来测试这个。
所以知道为什么会这样吗?更重要的是,如何解决它?