我正在尝试将视频文件加载到我的 iPad 应用程序中AVURLAsset
,使用异步加载的东西等待它准备好。问题是,当我运行它时,我收到一个完全通用的“失败”错误消息,我不知道该怎么办。如果我把它交给一个视频,它就可以工作MPMoviePlayerController
,但AVURLAsset
似乎拒绝与它有任何关系。
代码:
asset = [[AVURLAsset alloc] initWithURL:[NSURL URLWithString:[docPath stringByAppendingPathComponent:@"video.mov"]] options:nil];
[asset loadValuesAsynchronouslyForKeys:[NSArray arrayWithObject:@"tracks"] completionHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
[self composeIfReady];
});
}];
...
- (void)composeIfReady
{
NSError *error = nil;
if([asset statusOfValueForKey:@"tracks" error:&error] == AVKeyValueStatusFailed)
NSLog(@"error loading: %@", [error description]);
if(error == nil)
NSLog(@"okay awesome");
}
输出:
error loading: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation couldn’t be completed. (AVFoundationErrorDomain error -11800.)" UserInfo=0x1696f0 {NSUnderlyingError=0x169a40 "The operation couldn’t be completed. (OSStatus error -12936.)"}
顺便说一下,-11800 是“未知错误”的错误代码。有点死胡同。有任何想法吗?在尝试加载资产之前,我应该设置什么吗?