0
비디오 경로가 있습니다. 이 경로를 사용하여 비디오에서 비디오를로드 할 수 있습니다.파일 경로에서 비디오 정보 가져 오기
이제 db의 비디오 정보를 원하지만 내 Cursor
은 항상 null입니다. 다음은 제 코드입니다.
String videoPath=Uri.fromFile(new File("/storage/emulated/0/Android/data/files/1483767006415.mp4")
final String[] projection = new String[]{MediaStore.Video.Media._ID, MediaStore.Video.Media.DISPLAY_NAME, MediaStore.Video.Media.DATA,
MediaStore.Video.Media.DURATION};
CursorLoader loader = new CursorLoader(getActivity(), contentUri, projection, null, null, null);
Cursor cursor = loader.loadInBackground();
if (cursor != null && cursor.moveToFirst()) {
long id = cursor.getLong(cursor.getColumnIndex(projection[0]));
String name = cursor.getString(cursor.getColumnIndex(projection[1]));
String path = cursor.getString(cursor.getColumnIndex(projection[2]));
long duration = cursor.getLong(cursor.getColumnIndex(projection[3]));
cursor.close();
return new ImageObject(id, name, path, false, MEDIA_TYPE_VIDEO, duration);
}
uri가 적절하지 않은 것으로 보입니다.
감사합니다.
이렇게하면됩니다. 그것은 당신을 위해 일할 수도 있습니다 http://stackoverflow.com/questions/13613443/android-mediastore-video-query-is-returning-null – Gautam
@ Gautam : nope. 작동하지 않습니다. 이 링크를 확인했습니다. – Beena