I’m very new to mac development and I have a hard time understanding how all this Cocoa stuff works.
Right now I’m working on getting still images from a video file and in order to do so, I need to load my video file (asset).
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]);
}
}];
After this code is executed I’m getting the following message:
NSView Controller[644:4413] Failed with error: The operation could not be completed
Does anyone know how to solve this problem I’m having?
Thank you!!!
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 befile:///Users/EVG/Desktop/myfile.mp4.