读取手机相册里的视频文件肯定是从数据库里面读取, 强大的MediaStore.Video 类里面有所有我们需要的信息,文件名称, 时长,类型, 大小等等, 我这里做了封装和展示, 分文件夹读取。
立竿见影上个效果图:
创建一个视频信息类
存储从数据库读取出来的视频信息
public class Video {
private int id;
private String title;
private String album;
private String artist;
private String displayName;
private String mimeType;
private String path;
private long size;
private long duration;
//缩略图
private Bitmap thumbnail;
}
提供一个获取所有视频信息的provider
public class VideoProvider implements AbstructProvider {
private Activity context;
public VideoProvider(Activity context) {
this.context = context;
}
@Override
public List<?> getList() {
List<Video> list = null;
BitmapFactory.Options options = new BitmapFactory.Options();
options.inDither = false;
options.inPreferredConfig = Bitmap.Config.ALPHA_8;
ContentResolver contentResolver = context.getContentResolver();
if (context != null) {
Cursor cursor = contentResolver.query(