I am using AVPlayer in my chat application but i am getting the fallowing error in selected audio files but the audio files correctly play in browser.
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x60800024fde0 {Error Domain=NSOSStatusErrorDomain Code=-16170 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-16170), NSLocalizedDescription=The operation could not be completed}
I am implementing the following methods.
-(void)setupAVPlayerForURL:(NSURL*)url
{
AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
AVPlayerItem *anItem = [AVPlayerItem playerItemWithAsset:asset];
playerAud = nil;
playerAud = [AVPlayer playerWithPlayerItem:anItem];
[self startTimer];
[playerAud play];
[anItem addObserver:self forKeyPath:@"status" options:NSKeyValueObservingOptionNew context:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopAudioPlay) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];
}
And also implement the fallowing observer.
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
//// playerAud is instance of AVPlayer
if (object == playerAud.currentItem && [keyPath isEqualToString:@"status"]) {
if (playerAud.currentItem.status == AVPlayerItemStatusFailed) {
NSLog(@"------player item failed:%@",playerAud.currentItem.error);
}
}
}
It prints the above error.