I use AVPlayer in my chat application, but I get an error in the selected audio files, but the audio files play correctly in the browser.
Domain error = AVFoundationErrorDomain Code = -11800 "Operation may not fill out" UserInfo = {NSUnderlyingError = 0x60800024fde0 {Error Domain = NSOSStatusErrorDomain Code = -16170 "(null)"}, NSLocalizedFailureReason = An unknown error was encountered (non-specific) -16 can be completed}
I implement 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 {
source share