gpt4 book ai didi

android - 如何从 Android 中的 .mov 文件中获取缩略图?

转载 作者:太空狗 更新时间:2023-10-29 14:16:18 24 4
gpt4 key购买 nike

我使用以下代码获取JPGAVI 文件的缩略图,但无法从.mov 文件中获取缩略图。

String[] projection_image = { MediaStore.Images.Media.DATA, MediaStore.Images.Media._ID, };
String[] projection_video = { MediaStore.Video.Media.DATA, MediaStore.Video.Media._ID, };

File file = new File(viewTag.mFileNode.mName) ;
String tempfilePath = file.getPath();

String whereClause_image = MediaStore.Images.Media.DATA + " = '" + tempfilePath + "'";
String whereClause_video = MediaStore.Video.Media.DATA + " = '" + tempfilePath + "'";

ContentResolver cr = getActivity().getContentResolver();
Cursor image_cursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection_image, whereClause_image, null, null);
Cursor video_cursor = cr.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection_video, whereClause_video, null, null);

try {

if(image_cursor.moveToFirst()){
long thumID = image_cursor.getLong(image_cursor.getColumnIndex("_ID"));
Bitmap bitmap_image = MediaStore.Images.Thumbnails.getThumbnail(getActivity().getContentResolver(), thumID, Images.Thumbnails.MICRO_KIND, null);

viewTag.mThumbnail.setImageBitmap(bitmap_image) ;

}

if(video_cursor.moveToFirst()){
long thumID = video_cursor.getLong(video_cursor.getColumnIndex("_ID"));
Bitmap bitmap_video = MediaStore.Video.Thumbnails.getThumbnail(getActivity().getContentResolver(), thumID, Video.Thumbnails.MICRO_KIND, null);
viewTag.mThumbnail.setImageBitmap(bitmap_video) ;
}

} catch (NullPointerException e) {
// TODO: handle exception
Log.i(TAG, "cursor---NullPointerException");

image_cursor = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection_image, whereClause_image, null, null);
video_cursor = cr.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projection_video, whereClause_video, null, null);

} finally{
image_cursor.close();
video_cursor.close();
}

有人知道如何在 Android 中使用 MediaStore 从 .mov 文件中获取缩略图吗?

最佳答案

Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path,
MediaStore.Images.Thumbnails.MINI_KIND);

关于android - 如何从 Android 中的 .mov 文件中获取缩略图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21694219/

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