[英]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.