Ios 当MPMoviePlayerController正在播放时,有没有办法拍摄屏幕截图

Ios 当MPMoviePlayerController正在播放时,有没有办法拍摄屏幕截图,ios,xcode,mpmovieplayercontroller,screenshot,capture,Ios,Xcode,Mpmovieplayercontroller,Screenshot,Capture,我尝试了以下步骤来捕捉截图,但MPMoviePlayerController却遇到了黑色背景 -(UIImage*)screenshot { CGSize imageSize = [[UIScreen mainScreen] bounds].size; CGFloat imageScale = imageSize.width / FRAME_WIDTH; if (NULL != UIGraphicsBeginImageContextWithOptions) UIGraphicsBe

我尝试了以下步骤来捕捉截图,但MPMoviePlayerController却遇到了黑色背景

-(UIImage*)screenshot
{
 CGSize imageSize = [[UIScreen mainScreen] bounds].size;

CGFloat imageScale = imageSize.width / FRAME_WIDTH;

if (NULL != UIGraphicsBeginImageContextWithOptions)
    UIGraphicsBeginImageContextWithOptions(imageSize, NO, imageScale);
else
    UIGraphicsBeginImageContext(imageSize);

CGContextRef context = UIGraphicsGetCurrentContext();

for (UIWindow *window in [[UIApplication sharedApplication] windows]) 
{
    if (![window respondsToSelector:@selector(screen)] || [window screen] == [UIScreen mainScreen])
    {
        CGContextSaveGState(context);

        CGContextTranslateCTM(context, [window center].x, [window center].y);

        CGContextConcatCTM(context, [window transform]);

        CGContextTranslateCTM(context,
                              -[window bounds].size.width * [[window layer] anchorPoint].x,
                              -[window bounds].size.height * [[window layer] anchorPoint].y);

        [[window layer] renderInContext:context];

        CGContextRestoreGState(context);
    }
}

UIImage *image = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return image;
}

MPMoviePlayerController
中获取
图像
,就像在
按钮的
操作
上这样:

-(void)getScreenShotOfMPMoviePlayerController:(MPMoviePlayerController *)mpPlayer
{
   UIImage *thumbnail = [mpPlayer thumbnailImageAtTime:yourMoviePlayerObject.currentPlaybackTime 
                       timeOption:MPMovieTimeOptionNearestKeyFrame];
}
编辑
合并
两个
图像
作为从
MPMoviePlayerController
拍摄的一个图像,使用
屏幕截图
ui窗口
拍摄


请参阅合并链接。

但是,它只提供MPMoviePlayerController的缩略图。使用MPMoviePlayerController,屏幕上还有其他元素,我希望一次捕获所有元素。现在不推荐使用此方法,改用什么?@Stas我认为现在使用的正确方法是
requestThumbnailImagesAtTimes