我正在尝试创建一个应用程序,我在MPMoviePlayerController中播放视频。如果视频暂停,则会截取thumbnailImageAtTime的屏幕截图。问题是暂停后显示图像MPMoviePlayerController,而我用thumbnailImageAtTime获取的屏幕截图不一样。
我的代码如下所示:
[self.moviePlayer pause]
[self.moviePlayer thumbnailImageAtTime:self.moviePlayer.currentPlaybackTime timeOption:MPMovieTimeOptionExact];
非常感谢任何帮助:)
答案 0 :(得分:0)
我使用的是MPMovieTimeOptionNearestKeyFrame
- (UIImage *)imageFromMovie:(NSURL *)movieURL atTime:(NSTimeInterval)time {
// set up the movie player
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc]
initWithContentURL:movieURL];
mp.shouldAutoplay = NO;
mp.initialPlaybackTime = time;
mp.currentPlaybackTime = time;
// get the thumbnail
UIImage *thumbnail = [mp thumbnailImageAtTime:time
timeOption:MPMovieTimeOptionNearestKeyFrame];
// clean up the movie player
[mp stop];
[mp release];
return(thumbnail);
}
试试这个