use of org.fourthline.cling.support.model.item.Movie in project BeyondUPnP by kevinshine.
the class MediaResourceDao method getVideoList.
public static List<Item> getVideoList(String serverUrl, String parentId) {
List<Item> items = new ArrayList<>();
Cursor c = BeyondApplication.getApplication().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Video.Media.TITLE);
c.moveToFirst();
while (!c.isAfterLast()) {
long id = c.getLong(c.getColumnIndex(MediaStore.Audio.Media._ID));
String title = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE));
String creator = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST));
String data = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
//Remove SDCard path
data = data.replaceFirst(storageDir, "");
//Replace file name by "id.ext"
String fileName = data.substring(data.lastIndexOf(File.separator));
String ext = fileName.substring(fileName.lastIndexOf("."));
data = data.replace(fileName, File.separator + id + ext);
String mimeType = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
long size = c.getLong(c.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
long duration = c.getLong(c.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
//Get duration string
String durationStr = ModelUtil.toTimeString(duration);
//Compose audio url
String url = serverUrl + File.separator + "video" + File.separator + data;
Res res = new Res(mimeType, size, durationStr, null, url);
items.add(new Movie(String.valueOf(id), parentId, title, creator, res));
c.moveToNext();
}
return items;
}