Manikandan K
Manikandan K

Reputation: 117

How to take a screenshot when video playing?

How to take screen shot when video playing? I used MPMoviePlayerController for video playing.

Upvotes: 1

Views: 1126

Answers (1)

Maulik
Maulik

Reputation: 19418

- (UIImage *) captureScreen 
{
    UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
    CGRect rect = [keyWindow bounds];
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    [keyWindow.layer renderInContext:context];   
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}

Upvotes: 4

Related Questions