[英]Android ThumbnailUtils.createVideoThumbnail with no Size specified is deprecated in API level 29
public static Bitmap createVideoThumbnail (String filePath,
int kind)
The above method is deprecated in API
level 29.上述方法在
API
级别 29 中已弃用。
We are required to use this now:我们现在需要使用它:
public static Bitmap createVideoThumbnail (File file,
Size size,
CancellationSignal signal)
My question is how can I set the Size
to be the native size of the video File
that I am creating the thumbnail from ?我的问题是如何将
Size
设置为我从中创建缩略图的视频File
的本机大小?
I want it to be the same height/width and dimensions
.我希望它具有相同的
height/width and dimensions
。
Before, I could just use ThumbnailUtils.createVideoThumbnail(file_path, MediaStore.Images.Thumbnails.FULL_SCREEN_KIND)
;以前,我可以只使用
ThumbnailUtils.createVideoThumbnail(file_path, MediaStore.Images.Thumbnails.FULL_SCREEN_KIND)
;
Use MediaMetadataRetriever class to get the size.使用 MediaMetadataRetriever class 获取大小。 Size will be equal to the size of video file created.
大小将等于创建的视频文件的大小。
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.