2013-04-29 73 views
1

正如标题后流站,我想生活在两个的iOS和使用AVPlayer例如OS X流互联网广播。一切正常,如预期一样简单player = [AVPlayer playerWithURL:URL];AVPlayer实况广播15分钟左右

使用该应用程序时,我注意到,流只是在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被解雇。

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

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

回答

1

好的,我注意到player.currentTime卡住了,而player.rate是。因此,至少在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 
+0

不错的工作!我相信AVPlayer存在问题,因为发生卡住时,AVPlayer的定期观察者不会再被解雇。 – wao813 2017-04-24 17:14:19