有人可以幫我嗎?我想通過MPMediaPlayerController播放視頻獲取屏幕截圖。什麼到目前爲止,我已經試過是: -如何在iPhone中通過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];
}
什麼,我已經現在得到的是這樣的: -
現在發生的事情是我的球員的按鈕越來越在擷取屏幕畫面,但我視頻的圖像沒有越來越多。我使用這種上下文方法來捕捉我的圖像,因爲 我有一個覆蓋在我的視頻,使用縮略圖的方法,我不能捕捉視頻與覆蓋,但我想獲得覆蓋視頻的圖像。
編輯: 我要的是讓這兩個視頻的截圖和繪圖疊加,如圖這一形象
什麼,但什麼IM越來越是一個方法我只有視頻不是我的截圖覆蓋該方法是縮略圖方法,我正在縮略圖,這是由MPMoviePlayerController給出的,並通過第二種方法即時獲取只覆蓋不是一個視頻在ma屏幕截圖,該方法是上下文method.i'm獲取rect的上下文。現在我認爲解決方案因爲這可能是ki結合這兩個圖像。所以幫助我通過提供建議合併圖像將適用於我嗎?
請help.Thanks :)
你用openGL? – zahreelay
否一點也不,我使用MediaPlayer框架來播放沒有別的東西我用過的視頻:) –