AVPlayerItem AVPlayerStatusFailed Status When Playing Video

I have implemented video playback for several videos using AVPlayer . When I play the following video, sometimes it shows this error message:

Domain error = AVFoundationErrorDomain Code = -11850 "Operation stopped" UserInfo = 0x1744796c0 {NSUnderlyingError = 0x170055db0 "Operation could not be completed. (OSStatus error -12939.)", NSLocalizedFailureReason = Server is configured incorrectly. NSLocalizedDescription = Operation stopped}

I found that Error 11850 : AVErrorServerIncorrectlyConfigured , which means that

The HTTP server sending the media resource is not configured as expected. This may mean that the server does not support byte range requests.

Please help me in this case, this is my video playback code

 - (void)playVideoWithUrl:(NSString *) videoUrl { if (player != nil) { [player.currentItem removeObserver:self forKeyPath:@"status"]; [player.currentItem removeObserver:self forKeyPath:@"playbackLikelyToKeepUp"]; } AVURLAsset * asset = [[AVURLAsset alloc]initWithURL:[NSURL URLWithString:videoUrl] options:nil]; AVPlayerItem * item = [[AVPlayerItem alloc]initWithAsset:asset]; // Add KVO to detech status of loading video [item addObserver:self forKeyPath:@"status" options:0 context:nil]; // Add KVO to detech when playback is loading buffer successfully [item addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:0 context:nil]; // Detect when playback completed [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[player currentItem]]; [player replaceCurrentItemWithPlayerItem:item]; [player play]; } 
+6
source share

All Articles