Why can't I capture a screenshot of MPMoviePlayerController?

I need to capture a screenshot of the video being played in the mpmovieplayer controller, but all I get is a red screen (I made a coverView with a red background and 0.5 alpha).

Here is the code:

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);
}

Any ideas ???

thanks

+3
source share
3 answers

I myself was curious. I believe there are similar problems with screenshots from OpenGL material.

If you look at this blog post http://getsetgames.com/2009/07/30/5-ways-to-take-screenshots-of-your-iphone-app/ , they have a method that works for EAGLView it may be worth it go for your problem.

+2

:

, , , , . , , , .

MPMoviePlayerController , UIImage , .

- (UIImage *)thumbnailImageAtTime:(NSTimeInterval)playbackTime timeOption:(MPMovieTimeOption)option

, , bingo, UIImage.


, , mpmovieplayer. , , , , -, .

, , ? .

+2

It looks like you are shooting a video overlay mask http://en.wikipedia.org/wiki/Hardware_overlay

0
source

Source: https://habr.com/ru/post/1724935/


All Articles