【发布时间】:2012-05-14 12:03:59
【问题描述】:
有人可以帮我吗?我想从通过 MPMediaPlayerController 播放的视频中获取屏幕截图。到目前为止我尝试过的是:-
-(void)viewDidLoad
{
NSURL *tempFilePathURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"LMFao" ofType:@"mp4"]];
player = [[MPMoviePlayerController alloc] initWithContentURL:tempFilePathURL];
[player setControlStyle:MPMovieControlStyleFullscreen];
//Place it in subview, else it won’t work
player.view.frame = CGRectMake(0, 0, 320, 400);
[self.view addSubview:player.view];
}
-(IBAction)screenshot
{
CGRect rect = [player.view bounds];
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[player.view.layer renderInContext:context];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
imgView = [[UIImageView alloc] initWithFrame:CGRectMake(150, 150, 100, 100)];
[imgView setImage:image];
imgView.layer.borderWidth = 2.0;
[self.view addSubview:imgView];
}
而我现在得到的是:-
现在发生的情况是我的播放器按钮在 ScreenShot 中被捕获,但我的视频图像没有被捕获。我正在使用此上下文方法来捕获我的图像,因为 我的视频上有一个叠加层,使用缩略图方法我无法捕获带有叠加层的视频,但我想获取带有叠加层的视频图像。
编辑: 我想要的是获取此视频和绘图叠加层的屏幕截图,如图所示
但我得到的是通过一种方法,我在我的屏幕截图中只得到了视频而不是覆盖,该方法是缩略图方法,我正在使用 MPMoviePlayerController 给出的缩略图,而通过第二种方法,我只得到覆盖而不是 ma 中的视频屏幕截图,该方法是上下文方法。我正在获取 rect 的上下文。现在我认为解决方案可能是 ki 将这两个图像结合起来。所以通过给出建议来帮助我合并图像是否适合我???
请帮忙。谢谢:)
【问题讨论】:
-
No 一点也不,我正在使用 MediaPlayer 框架播放视频,我没有用过其他任何东西:)
标签: iphone objective-c image mpmovieplayercontroller image-capture