.getColumnIndexOrThrow(MediaStore.Video.Media._ID));
String title = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE));
String album = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.ALBUM));
String artist = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST));
String displayName = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME));
String mimeType = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
String path = cursor
.getString(cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
long duration = cursor
.getInt(cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
long size = cursor
.getLong(cursor
.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
Video video = new Video(id, title, album, artist, displayName, mimeType, path, size, duration);
list.add(video);
}
cursor.close();
}
}
return list;
}
}
最后在主类中使用如下代码来获取最终得到的视频相关信息集合
AbstructProvider provider = new VideoProvider(this);
List
在上面的listVideos包含了本地所有的视频的相关信息,下一章将会用 listVideos数据。