【发布时间】:2011-05-05 07:44:06
【问题描述】:
我正在尝试将视频文件以AVURLAsset 的形式加载到我的 iPad 应用程序中,并使用异步加载内容等待它准备好。问题是,当我运行它时,我收到一个完全通用的“失败”错误消息,我不知道该怎么办。如果我将视频交给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,顺便说一下,是“未知错误”的错误代码。有点死胡同。有任何想法吗?在尝试加载资产之前我应该设置什么?
【问题讨论】:
标签: ipad video ios avfoundation ios4