先用requestThumbnailImagesAtTimes方法获取thumbnailImage:
MPMoviePlayerController *aplayer = [[MPMoviePlayerController alloc] initWithContentURL:_mediaUrl];
self.moviePlayer = aplayer;
_moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
_moviePlayer.view.frame = _moviePic.bounds;
_moviePlayer.shouldAutoplay = NO;
[_moviePlayer prepareToPlay];
[_moviePlayer requestThumbnailImagesAtTimes:[NSArray arrayWithObject:[NSNumber numberWithDouble:1.0]] timeOption:MPMovieTimeOptionExact];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(movieThumbnailLoadComplete:) name:MPMoviePlayerThumbnailImageRequestDidFinishNotification object:nil];
[aplayer release];
接收消息
-(void)movieThumbnailLoadComplete:(NSNotification*)notification
{
NSLog(@"%@",notification.userInfo);
NSDictionary *userInfo = [notification userInfo];
UIImage *image =[userInfo objectForKey: @"MPMoviePlayerThumbnailImageKey"];
}
打印出来的thumbnail image总是nan,到底是为什么呢?是不是只能获取本地视频的缩略图呢?