簡體   English   中英

錯誤域 = AVFoundationErrorDomain 代碼 = -11800 “操作無法完成。錯誤域 = NSOSStatusErrorDomain 代碼 = -16170 “(空)”

[英]Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed. Error Domain=NSOSStatusErrorDomain Code=-16170 "(null)"

我在我的聊天應用程序中使用 AVPlayer,但在選定的音頻文件中出現了錯誤,但音頻文件在瀏覽器中正確播放。

錯誤域=AVFoundationErrorDomain 代碼=-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.

就我而言,我使用 http url.Set NSAllowsArbitraryLoads to YES修復錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM