【发布时间】:2012-09-26 12:48:10
【问题描述】:
我将捕获的视频保存在如下所示的文档目录中,现在我想显示缩略图并播放相同的视频。如何做到这一点?
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info
{
NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
[self dismissModalViewControllerAnimated:NO];
// Handle a movie capture
if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo)
{
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSString *movieName = [NSString stringWithFormat:@"%@.mov",[CoreDataFunctions getNameForVideoForDate:[CalendarFunctions getCurrentDateString]]];
NSString *moviePath = [documentsDir stringByAppendingPathComponent:movieName];
NSURL * movieURL = [info valueForKey:UIImagePickerControllerMediaURL];
NSData * movieData = [NSData dataWithContentsOfURL:movieURL];
NSLog(@"%@",moviePath);
if([movieData writeToFile:moviePath atomically:NO])
{
if(![CoreDataFunctions saveVideoInfoInDatabaseForDate:[CalendarFunctions getCurrentDateString]])
{
NSLog(@"Video was saved in doucment directory but could not be saved in core data");
}
}
else
{
NSLog(@"Video could not be saved to the document directry");
}
}
}
【问题讨论】:
标签: iphone objective-c ios ios5 ios4