2011-02-15 110 views
2

可能重複:
How to get thumbnail for video in my /sdcard/Android/data/mypackage/files folder ?顯示視頻縮略圖的Android

您好所有

在我的Android應用程序,我正在錄製視頻和SD卡中保存此。 現在我需要的是在我的應用程序中以縮略圖形式顯示此視頻。

我試過Android: Is it possible to display video thumbnails?的所有解決方案 問題是我需要從SD卡路徑的視頻,我不理解如何得到它。

我嘗試下面的代碼

int id = **"The Video's ID"** 
ImageView iv = (ImageView) convertView.findViewById(R.id.imagePreview); 
ContentResolver crThumb = getContentResolver(); 
BitmapFactory.Options options=new BitmapFactory.Options(); 
options.inSampleSize = 1; 
Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id,MediaStore.Video.Thumbnails.MICRO_KIND, options); 
iv.setImageBitmap(curThumb); 

但不能理解爲如何從SD卡路徑視頻。

請分享您的寶貴建議

感謝提前:)

回答

0

您可以檢查出ThumbnailUtilsthis answer,前提是你在Android 8(升級Froyo)或更高版本。