Skip to content

Instantly share code, notes, and snippets.

@yanguango
Created October 19, 2010 15:38
Show Gist options
  • Save yanguango/634399 to your computer and use it in GitHub Desktop.
Save yanguango/634399 to your computer and use it in GitHub Desktop.
NSString *video_url = @"http://www.youtube.com/v/2mTS5gGkK9k?fs=1&hl=en_US";
//NSData *video_data = [NSData dataWithContentsOfURL: picture_url];
MPMoviePlayerController *movieController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:video_url]];
UIImage *videoThumb = nil;
if ([movieController respondsToSelector:@selector(thumbnailImageAtTime:timeOption:)])
{
NSLog(@"===============xxxxxxxxxxx=========================");
videoThumb = [movieController thumbnailImageAtTime:(NSTimeInterval)2.0 timeOption: MPMovieTimeOptionNearestKeyFrame];
}
[videoThumb compressDownTo:200.0];
CGRect mediaFrame = CGRectMake((300 - videoThumb.size.width) / 2,
mediaTopMargin,
videoThumb.size.width,
videoThumb.size.height);
UIImageView *videoView = [[UIImageView alloc] initWithFrame:mediaFrame];
videoView.image = videoThumb;
[self.view addSubview:videoView];
[videoView release];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment