AVPlayer直播无线电流在15分钟后停止播放

时间:2013-04-29 11:22:50

标签: ios xcode macos avplayer

作为标题,我正在尝试使用AVPlayer实例在 iOS OS X 上直播互联网广播。通过简单的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我观察到被解雇了。

花了一段时间来测试这个。

所以任何想法为什么会发生这种情况?更重要的是,如何解决它?

1 个答案:

答案 0 :(得分:1)

好的,我注意到player.currentTimeplayer.rate 1 时卡住了。所以至少在OS X上我可以跟踪它并在卡住时重启流。

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