2014-08-30 72 views

回答

0

您可以用波纹管代码中创建视频缩略图:

-(UIImage *)getThumbNail:(NSString*)stringPath // string path is a path of you video file 
{ 
    NSURL *urlvideoImage =[NSURL fileURLWithPath:stringPath]; 

    AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:urlvideoImage options:nil]; 
    AVAssetImageGenerator *generateImg = [[AVAssetImageGenerator alloc] initWithAsset:asset]; 
    NSError *error = NULL; 
    CMTime time = CMTimeMake(1, 65); 
    CGImageRef refImg = [generateImg copyCGImageAtTime:time actualTime:NULL error:&error]; 
    NSLog(@"error==%@, Refimage==%@", error, refImg); 

    UIImage *FrameImage= [[UIImage alloc] initWithCGImage:refImg]; 


// 
    return FrameImage; 
} 
  • 使用上面的代码从您的视频URL创建缩略图。
  • 将此图像设置为按钮背景图像,或者您可以使用图像查看并设置点按手势,忘记它是触摸事件。
  • 通过点击按钮,您可以播放视频与相关的代码。希望这是为你工作。
+0

感谢我得到的略图,但图像dosenot适合我imageview.i已经使用这个代码: - [滚动视图的Alloc] initWithFrame:方法CGRectMake(0,0,_movieView.bounds.size.width,_movieView.bounds。 size.height)] – apple10 2014-08-30 09:54:51

+0

设置图像视图包含模式:yourImageview.contentMode = UIViewContentModeScaleAspectFit; – 2014-08-30 09:56:02