MPMoviePlayerController拍摄屏幕截图但仅显示黑屏

时间:2012-06-29 08:52:11

标签: iphone

我在播放MPMoviePlayerController时拍摄截图。完美保存屏幕截图但图像仅为黑色。我使用下面的代码。

UIGraphicsBeginImageContext(self.moviePlayerController.view.frame.size);
[self.moviePlayerController.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);

2 个答案:

答案 0 :(得分:3)

最后我解决了这个问题...我正在使用这个代码......完美的工作......感谢所有......

- (void)captureScreenShot
{
    CGImageRef originalImage = UIGetScreenImage();
    CGImageRef videoImage = CGImageCreateWithImageInRect(originalImage, CGRectMake(0, 66, 320, 230));            
    UIImage *snapShotImage = [UIImage imageWithCGImage:videoImage];
    UIImageWriteToSavedPhotosAlbum(snapShotImage, nil, nil, nil);
    CGImageRelease(originalImage);                
    CGImageRelease(videoImage);  
}

答案 1 :(得分:0)

您可以尝试使用thumbnailImageAtTime的{​​{1}}方法。

MPMoviePlayerController