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

前端 未结 3 1376
借酒劲吻你
借酒劲吻你 2020-12-16 07:02

Can anybody help me in this? I want to get an screenshot from an video playing through MPMediaPlayerController. What i have tried so far is:-

-(void)viewDidL         


        
相关标签:
3条回答
  • 2020-12-16 07:15

    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;
    }
    
    0 讨论(0)
  • 2020-12-16 07:22

    This may help

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

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

    0 讨论(0)
  • 2020-12-16 07:33

    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.

    0 讨论(0)
提交回复
热议问题