我需要捕获在mpmovieplayer控制器中播放的视频的屏幕截图,但我得到的只是一个红色屏幕(我用红色背景和0.5 alpha制作了coverView)。为什么我无法捕获MPMoviePlayerController的屏幕截图?
下面是代码:
NSArray *windows = [[UIApplication sharedApplication] windows];
if ([windows count] > 1)
{
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
UIView *coverView = [[UIView alloc] initWithFrame:moviePlayerWindow.bounds];
[mainController.moviePlayer pause]; //Without that it won't work either!
coverView.backgroundColor = [UIColor redColor];
coverView.alpha = 0.5;
[moviePlayerWindow addSubview:coverView];
UIGraphicsBeginImageContext(coverView.bounds.size);
[coverView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot;
screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(screenShot, self, nil, nil);
}
任何想法?
感谢
我不认为它必须做用OpenGL – Alex1987 2009-12-07 18:20:26