作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在聊天应用程序中使用了AVPlayer,但是在选择的音频文件中出现了休闲错误,但是音频文件在浏览器中正确播放。
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}
-(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
修复错误。
关于ios - 错误域= AVFoundationErrorDomain代码= -11800 “The operation could not be completed. Error Domain=NSOSStatusErrorDomain Code=-16170 ”(空)“,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42344757/
我是一名优秀的程序员,十分优秀!