0

我对 mac 开发非常陌生,我很难理解所有这些 Cocoa 的东西是如何工作的。

现在我正在从视频文件中获取静止图像,为此,我需要加载我的视频文件(资产)。

NSURL *url = [[NSURL alloc]initWithString:@"/Users/EVG/Desktop/myfile.mp4"];

AVURLAsset *myAsset = [[AVURLAsset alloc] initWithURL:url options:nil];

NSArray *keys = @[@"tracks"];

[myAsset loadValuesAsynchronouslyForKeys:keys completionHandler:^()
 {
     NSError *error = nil;
     AVKeyValueStatus tracksStatus = [myAsset statusOfValueForKey:@"tracks" error:&error];

     if ( tracksStatus == AVKeyValueStatusFailed ||
         tracksStatus == AVKeyValueStatusCancelled )
     {
         NSLog(@"Failed with error: %@", [error localizedDescription]);
     }
 }];

执行此代码后,我收到以下消息:

NSView 控制器 [644:4413] 失败并出现错误:操作无法完成

有谁知道如何解决我遇到的这个问题?

谢谢!!!

4

1 回答 1

2

Your URL is wrong. First of all, absolute file paths should begin with a /, as in /Users/EVG/Desktop/myfile.mp4. However, that's not a URL. A file URL should be file:///Users/EVG/Desktop/myfile.mp4.

于 2012-10-16T17:50:02.540 回答