安卓:从视频URI创建视频缩略图视频、缩略图、URI

2023-09-05 04:36:31 作者:烟花易冷人易散

我budiling一个应用程序,它列出了所有的视频​​记录我使用刻录机在列表中。是否有可能为我创造一个缩略图与乌里而不是字符串???

帮助

我目前的code变为如下,但它不再工作作为我的输入构造是开放的我们不串。

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

我返回的错误

 在类型ThumbnailUtils的方法createVideoThumbnail(字符串,INT)不适用于参数(URI,INT)
 

感谢您的时间提前。

解决方案

 公共字符串getRealPathFromURI(URI contentUri){
    的String []凸出= {MediaStore.Images.Media.DATA};
    光标光标= managedQuery(contentUri,凸出,NULL,NULL,NULL);
    INT与Column_Index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    返回cursor.getString(Column_Index中);
}
 
如何创建视频图层

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.

解决方案

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);
}