【问题标题】:Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed. Error Domain=NSOSStatusErrorDomain Code=-16170 "(null)"错误域 = AVFoundationErrorDomain 代码 = -11800 “操作无法完成。错误域 = NSOSStatusErrorDomain 代码 = -16170 “(空)”
【发布时间】:2017-07-09 17:51:09
【问题描述】:

我在我的聊天应用程序中使用 AVPlayer,但我在选定的音频文件中遇到错误,但音频文件在浏览器中正确播放。

Error Domain=AVFoundationErrorDomain Code=-11800 "该操作可能 未完成” UserInfo={NSUnderlyingError=0x60800024fde0 {错误 域=NSOSStatusErrorDomain 代码=-16170 "(null)"}, NSLocalizedFailureReason=发生未知错误(-16170), NSLocalizedDescription=操作无法完成}

我正在实现以下方法。

-(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.

【问题讨论】:

  • @thanks Amod Gokhale..但它不工作 fileURLWithPath 添加文件关键字与音频 url。
  • 这可能是特定 iOS 版本中的错误。我记得看到过这个,但更新操作系统后,问题就消失了。

标签: ios


【解决方案1】:

就我而言,我使用 http url.Set NSAllowsArbitraryLoads to YES 修复错误。

【讨论】:

  • 您好,欢迎来到 SO!请阅读tourHow do I write a good answer?,比如你可以详细说明你在哪里使用它,它有什么作用,它是如何解决问题的。
猜你喜欢
  • 2018-12-16
  • 2014-11-30
  • 2014-11-02
  • 2017-09-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-19
相关资源
最近更新 更多