这个比较简单 也比较实用
首先根据需要建一个本地视频的model类 可以包含时间 视频名字 地址等等属性 根据自己需要 我建立的如下
package com.example.yanshishow;
//电影视频的model类
public class MMM {
String name;
long size;
String url;
long duration;
public String getName1() {
return name;
}
public void setName1(String name) {
this.name = name;
}
public long getSize1() {
return size;
}
public void setSize1(long size) {
this.size = size;
}
public String getUrl1() {
return url;
}
public void setUrl1(String url) {
this.url = url;
}
public long getDuration1() {
return duration;
}
public void setDuration1(long duration) {
this.duration = duration;
}
}
然后就直接一个方法就可以了 方法如下
public List<MMM> getList() {
List<MMM> list = null;
if (this != null) {
Cursor cursor = this.getContentResolver().query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null, null,
null, null);
if (cursor != null) {
list = new ArrayList<MMM>();
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor
.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));
MMM video = new MMM();
video.setName1(title);
video.setSize1(size);
video.setUrl1(path);
video.setDuration1(duration);
list.add(video);
}
cursor.close();
}
}
return list;
}
这个方法返回的就是所有本地视频的信息 可以根据需要再去使用