How to take a screenshot from an video playing through MPMediaPlayerController in iPhone?

落花浮王杯 提交于 2019-11-29 02:37:58

U can merge two image from this way.Please have an look from the below code..

- (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *)maskImage {
    MaskView=[[UIView alloc] init];
    UIImageView *image1=[[UIImageView alloc]init];
    UIImageView *image2=[[UIImageView alloc]init];
    MaskView.frame=CGRectMake(0, 0,500,500);    
    image1.frame=CGRectMake(0,0,160, 160);  
    image2.frame=CGRectMake(60,54,40,40);
    image1.image=image;
    image2.image=maskImage;
    [MaskView addSubview:image1];
    [MaskView addSubview:image2];   

    UIGraphicsBeginImageContext(CGSizeMake(160,160));

    [MaskView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *finishedPic = UIGraphicsGetImageFromCurrentImageContext(); 

    return finishedPic;
}

You just have to call a single method on your mpmovieplayer object:

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

this method will return a UIImage object. what you have to do is just:

UIImage *thumbnail = [player thumbnailImageAtTime:1.0 timeOption:MPMovieTimeOptionNearestKeyFrame];

for more details look at MPMoviePlayerController

Hope this helps

EDIT: In your method you can first hide player's control and than capture Image after that show controls again. you can achive this using controlStyle property of MPMoviePlayerController.

Not sure this is what you are looking for but it is what I understood. If you are looking for different let me know.

This may help

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

Get the thumbnailImage at the given time and scale that image.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!