问题描述
我有一个应用程序,我可以拍摄视频,然后将其存储在核心数据中,并附带其他一些数据。它存储为可转换和存储在外部记录文件中。我将视频剪辑放入一个名为movie的对象中;
I have an app where I can shoot a video and then store it in core-data with some other data. It's stored as Transformable and "Store in External Record File". I get the video clip into an object called movie like this;
(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
movie = [info objectForKey:UIImagePickerControllerEditedImage];
我遇到的问题是从电影中获取缩略图。使用 MPMoviePlayerController
我必须有一个URL,但电影还没有存储在任何地方。另外,从核心数据中查找URL也是个谜。
Where I get stuck is to get a thumbnail from the movie. Using MPMoviePlayerController
I have to have an URL, but the movie isn't stored anywhere yet. Plus finding the URL from the core-data is a mystery as well.
我能在这里找到的最近的帮助是。但是我对URL问题感到困惑。
The closest help I can find here is Getting a thumbnail from a video url or data in iPhone SDK . But I get caught out on the URL issue.
我将它保存到这样的核心数据中;
I am saving it to core-data like this;
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *newMedia = [NSEntityDescriptioninsertNewObjectForEntityForName:@"Media" inManagedObjectContext:context];
[newMedia setValue:@"Video Clip " forKey:@"title"];
[newMedia setValue:now forKey:@"date_time"];
[newMedia setValue:movie forKey:@"movie"];
[newMedia setValue:[self generateImage] forKey:@"frame"];
如果有人可以给我指针,我将不胜感激。
I would be grateful if there is someone out there that can give me a pointer.
推荐答案
从电影中获取缩略图......
To get thumbnail from movie...
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if ([[info objectForKey:@"UIImagePickerControllerMediaType"] rangeOfString:@"movie"].location!=NSNotFound)
{
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:[info objectForKey:@"UIImagePickerControllerMediaURL"]];
theMovie.view.frame = self.view.bounds;
theMovie.controlStyle = MPMovieControlStyleNone;
theMovie.shouldAutoplay=NO;
UIImage *imgTemp = [theMovie thumbnailImageAtTime:0 timeOption:MPMovieTimeOptionExact];
}
}
这篇关于从电影中获取缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!