[英]Android ThumbnailUtils.createVideoThumbnail with no Size specified is deprecated in API level 29
public static Bitmap createVideoThumbnail (String filePath,
int kind)
上述方法在API
级别 29 中已弃用。
我们现在需要使用它:
public static Bitmap createVideoThumbnail (File file,
Size size,
CancellationSignal signal)
我的问题是如何将Size
设置为我从中创建缩略图的视频File
的本机大小?
我希望它具有相同的height/width and dimensions
。
以前,我可以只使用ThumbnailUtils.createVideoThumbnail(file_path, MediaStore.Images.Thumbnails.FULL_SCREEN_KIND)
;
使用 MediaMetadataRetriever class 获取大小。 大小将等于创建的视频文件的大小。
public static Size getThumbSize(String path) {
MediaMetadataRetriever dataRetriever = new MediaMetadataRetriever();
dataRetriever.setDataSource(path);
String width =
dataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
String height =
dataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
return new Size(Integer.parseInt(width), Integer.parseInt(height));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.