Android: Creating video thumbnails from Video URI

强颜欢笑 提交于 2020-01-01 03:25:10

问题


I'm budiling an application and it lists all the videos i recorded using the recorder in a list. Is it possible for me to create a thumbnail with the help of Uri instead of the string???

my current code goes as below but it no longer works as my input to the constructor is Uri not string.

bmThumbnail = ThumbnailUtils.createVideoThumbnail(
                    (db_results.get(position)), Thumbnails.MICRO_KIND);
            imageThumbnail.setImageBitmap(bmThumbnail);

I'm returned the error

The method createVideoThumbnail(String, int) in the type ThumbnailUtils is not applicable for the arguments (Uri, int)

Thanks for your time in advance.


回答1:


public String getRealPathFromURI(Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(contentUri, proj, null, null, null);
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}


来源:https://stackoverflow.com/questions/6977777/android-creating-video-thumbnails-from-video-uri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!