Ios AVPlayer直播广播流媒体在15分钟左右后停止

Ios AVPlayer直播广播流媒体在15分钟左右后停止,ios,xcode,macos,avplayer,Ios,Xcode,Macos,Avplayer,作为标题,我正在尝试使用AVPlayer实例在iOS和osx上直播互联网广播。通过一个简单的player=[AVPlayer playerWithURL:URL],一切都正常工作 在使用该应用程序时,我注意到流在15分钟后就停止了。问题是没有得到通知 [player addObserver:self forKeyPath:@"status" options:0 context:nil]; [player addObserver:self forKeyPath:@"rate" options:0

作为标题,我正在尝试使用
AVPlayer
实例在iOSosx上直播互联网广播。通过一个简单的
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上,右上角的播放图标消失了,但应用程序仍然认为由于播放器的原因会播放音频。速率值不会改变

首先,我认为这是一条流,所以我尝试了来自5by5和twit的其他流,同样的事情也发生了

然后我认为这是我的连接,所以在流启动后,我关闭了连接,大约一分钟后,我观察到的
AVPlayerItemDidPlayToEndTimeNotification
被触发

这需要一段时间来测试


你知道为什么会这样吗?更重要的是,如何修复它?

好的,我注意到
播放器.currentTime
被卡住了,而
播放器.rate
1。因此,至少在OSX上,我可以跟踪它并在卡住时重新启动流

2013-04-30 12:49:07.730 Radio[60315:303] rate -> 1.000000
2013-04-30 12:49:07.731 Radio[60315:303] status -> 1
2013-04-30 13:09:04.154 Radio[60315:303] Stuck at 1195 x 1
2013-04-30 13:09:05.155 Radio[60315:303] Stuck at 1195 x 2
2013-04-30 13:09:06.155 Radio[60315:303] Stuck at 1195 x 3
2013-04-30 13:09:07.155 Radio[60315:303] >> Stuck! Restart stream <<
2013-04-30 13:09:09.426 Radio[60315:303] rate -> 1.000000
2013-04-30 13:09:09.426 Radio[60315:303] status -> 1
2013-04-30 12:49:07.730无线电[60315:303]速率->1.000000
2013-04-30 12:49:07.731收音机[60315:303]状态->1
2013-04-30 13:09:04.154收音机[60315:303]卡在1195 x 1
2013-04-30 13:09:05.155收音机[60315:303]卡在1195 x 2的位置
2013-04-30 13:09:06.155收音机[60315:303]卡在1195 x 3
2013-04-30 13:09:07.155收音机[60315:303]>>卡住了!重新启动流1.000000
2013-04-30 13:09:09.426收音机[60315:303]状态->1

好的,我注意到
player.currentTime
被卡住了,而
player.rate
1。因此,至少在OSX上,我可以跟踪它并在卡住时重新启动流

2013-04-30 12:49:07.730 Radio[60315:303] rate -> 1.000000
2013-04-30 12:49:07.731 Radio[60315:303] status -> 1
2013-04-30 13:09:04.154 Radio[60315:303] Stuck at 1195 x 1
2013-04-30 13:09:05.155 Radio[60315:303] Stuck at 1195 x 2
2013-04-30 13:09:06.155 Radio[60315:303] Stuck at 1195 x 3
2013-04-30 13:09:07.155 Radio[60315:303] >> Stuck! Restart stream <<
2013-04-30 13:09:09.426 Radio[60315:303] rate -> 1.000000
2013-04-30 13:09:09.426 Radio[60315:303] status -> 1
2013-04-30 12:49:07.730无线电[60315:303]速率->1.000000
2013-04-30 12:49:07.731收音机[60315:303]状态->1
2013-04-30 13:09:04.154收音机[60315:303]卡在1195 x 1
2013-04-30 13:09:05.155收音机[60315:303]卡在1195 x 2的位置
2013-04-30 13:09:06.155收音机[60315:303]卡在1195 x 3
2013-04-30 13:09:07.155收音机[60315:303]>>卡住了!重新启动流1.000000
2013-04-30 13:09:09.426收音机[60315:303]状态->1

干得不错!我相信AVPlayer有问题,因为当卡住发生时,AVPlayer的周期性观察者将不再被解雇。干得好!我相信AVPlayer有问题,因为当卡住发生时,AVPlayer的周期性观察者将不再被解雇。