Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 检测与AVPlayerItem连接的短暂中断_Objective C_Avplayer_Key Value Observing - Fatal编程技术网

Objective c 检测与AVPlayerItem连接的短暂中断

Objective c 检测与AVPlayerItem连接的短暂中断,objective-c,avplayer,key-value-observing,Objective C,Avplayer,Key Value Observing,如果我启动此流,然后关闭wifi,“Playbackufferempty”将被触发,我可以尝试重新启动该流进行响应。但是,如果我立即关闭wifi并再次打开,则流将停止播放,但不会触发任何观察者 - (void)restartStream { [self.activityIndicator startAnimating]; NSLog(@"Removing Observers"); [self.radioStream removeObserver:self forKeyPa

如果我启动此流,然后关闭wifi,“Playbackufferempty”将被触发,我可以尝试重新启动该流进行响应。但是,如果我立即关闭wifi并再次打开,则流将停止播放,但不会触发任何观察者

- (void)restartStream
{
    [self.activityIndicator startAnimating];
    NSLog(@"Removing Observers");
    [self.radioStream removeObserver:self forKeyPath:@"status"];
    [self.radioStream removeObserver:self forKeyPath:@"timedMetadata"];
    [self.radioStream removeObserver:self forKeyPath:@"playbackBufferEmpty"];
    [self.radioStream removeObserver:self forKeyPath:@"playbackLikelyToKeepUp"];
    NSLog(@"Creating New AVPlayerItem");
    self.radioStream = [AVPlayerItem playerItemWithURL:[NSURL URLWithString:@"http://mystream.com"]];
    [self.radioStream addObserver:self forKeyPath:@"status" options:0 context:nil];
    [self.radioStream addObserver:self forKeyPath:@"timedMetadata" options:NSKeyValueObservingOptionNew context:nil];
    [self.radioStream addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil];
    [self.radioStream addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil];
    NSLog(@"Playing radioPlayer with new AVPlayerItem");
    self.radioPlayer = [AVPlayer playerWithPlayerItem:self.radioStream];
}

似乎是模拟器的问题。设备上会触发“状态”或“Playbackufferempty”