2014-08-30 2 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

덕분에 내가 thumnail를 얻었으나, 내 imageview.i이 코드를 사용했습니다에 이미지가 맞지 dosenot : - [있는 ScrollView ALLOC] initWithFrame : CGRectMake (0, 0, _movieView.bounds.size.width, _movieView.bounds. size.height)] – apple10

+0

설정 이미지보기 모드 포함 : yourImageview.contentMode = UIViewContentModeScaleAspectFit; –