1

作为标题,我正在尝试使用实例在iOSOS 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我观察到被解雇了。

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

所以知道为什么会这样吗?更重要的是,如何解决它?

4

1 回答 1

1

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

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-30T06:28:21.197 回答