Screenshot does not show the image in video
我需要单击按钮才能获得视频的屏幕截图。下面是用于该代码的代码,但是该图像仅显示了视频的底部,即随着时间的流逝而进行的播放和进度。已使用MPMoviePlayerController播放视频。
1 2 3 4 5 6 7 8 9 10 11 | CGRect rect = [_moviePlayer.view bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [_moviePlayer.view.layer renderInContext:context]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 100, 100, 100)]; [imgView setImage:image]; imgView.layer.borderWidth = 2.0; [_firstimage addSubview:imgView]; |
NSURL * url = [NSURL URLWithString:@" http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
它是这样显示的..我如何获得视频图像?谁能帮我..
1 2 3 4 5 6 7 8 9 10 | CGImageRef originalImage = UIGetScreenImage(); CGImageRef videoImage = CGImageCreateWithImageInRect(originalImage, CGRectMake(0, 0, 680, 300)); UIImage *snapShotImage = [UIImage imageWithCGImage:videoImage]; UIImageWriteToSavedPhotosAlbum(snapShotImage, nil, nil, nil); CGImageRelease(originalImage); CGImageRelease(videoImage); UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 100, 250, 200)]; [imgView setImage:snapShotImage]; imgView.layer.borderWidth = 2.0; [_firstimage addSubview:imgView]; |
此代码有效...感谢您的帮助...
如何使用