private String resolution = null;// 分辨率
private long size = 0;
private long date = 0;
private long duration = 0;
public Video(int id, String path, String name, String resolution, long size, long date, long duration) {
this.id = id;
this.path = path;
this.name = name;
this.resolution = resolution;
this.size = size;
this.date = date;
this.duration = duration;
}
… //此处省略setter和getter方法
}
通过本地视频id获取视频缩略图
// 获取视频缩略图
public Bitmap getVideoThumbnail(int id) {
Bitmap bitmap = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
bitmap = MediaStore.Video.Thumbnails.getThumbnail(mContentResolver, id, MediaStore.Images.Thumbnails.MICRO_KIND, options);
return bitmap;
}
上面获取视频列表的方法中,Video对象中有一个属性是id,通过传入这个id可以获取到视频缩略图的Bitmap对象。
获取本机所有图片文件夹
/**
- 得到图片文件夹集合
*/
public List getImageFolders() {
List folders = new ArrayList();
// 扫描图片
Cursor c = null;
try {
c = mContentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null,
MediaStore.Images.Media.MIME_TYPE + "= ? or " + MediaStore.Images.Media.MIME_TYPE + “= ?”,
new String[]{“image/jpeg”, “image/png”}, MediaStore.Images.Media.DATE_MODIFIED);
List mDirs = new ArrayList();//用于保存已经添加过的文件夹目录
while (c.moveToNext()) {
String path = c.getString(c.getColumnIndex(MediaStore.Images.Media.DATA));// 路径
File parentFile = new File(path).getParentFile();
if (parentFile ==