安卓:从视频URI创建视频缩略图 [英] Android: Creating video thumbnails from Video URI

查看:276
本文介绍了安卓:从视频URI创建视频缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这篇关于安卓:从视频URI创建视频缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆