When AVPlayerItem requests for downloading the audio stream, then randomly we get a failure response "IO: Stream cancelled by CLIENT". Audio download requests are divided into multiple stream requests by AVPlayerItem. Only the first stream request gives success response, the remaining stream request get failed. How we can resolve it?
AVPlayerItem *playerCurrentItem = [AVPlayerItem playerItemWithURL:songURL];
[self.playerCurrentItem addObserver:self forKeyPath:@"status" options:0 context:nil];
[self.playerCurrentItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:0 context:nil];
if (!self.player) {
self.player = [AVPlayer playerWithPlayerItem:self.playerCurrentItem];
} else {
[self.player replaceCurrentItemWithPlayerItem:self.playerCurrentItem];
}
if (self.player.rate == 0.0) {
self.player.automaticallyWaitsToMinimizeStalling = false;
[self.player playImmediatelyAtRate:1.0f];
}
Note:- XCode12.1 and running app in simulator with Charles proxy