gpt4 book ai didi

iPhone和iPad,播放视频时截图

转载 作者:行者123 更新时间:2023-12-03 21:18:28 26 4
gpt4 key购买 nike

我的应用程序需要在屏幕上播放视频时截取一些屏幕截图。视频由AVPlayer和AVPlayerLayer播放。当我尝试使用旧方法时出现的问题,例如:

UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
CGRect rect = [keyWindow bounds];

if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)])
UIGraphicsBeginImageContextWithOptions(rect.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(rect.size);

CGContextRef context = UIGraphicsGetCurrentContext();
[keyWindow.layer renderInContext:context];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;

它返回屏幕图像和黑色区域(视频应该在那里)。我可以使用 UIGetScreenImage() 成功截取屏幕截图,但它是私有(private) API,所以我不确定是否可以使用它

最佳答案

据我所知,许多已发布的应用程序一直在使用 UIGetScreenImage()。看来苹果对它的使用相当宽松。也许你可以冒险一下...

关于iPhone和iPad,播放视频时截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7622759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com