If I start this stream and then turn wifi off, "playbackBufferEmpty" is fired and I can respond by attempting to restart the stream. However if I turn wifi off and back on again straight away, the stream stops playing but none of the observers are triggered.
- (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];
}
Seems to be an issue with the simulator. "status" or "playbackBufferEmpty" are triggered on the device.