I am writing a music player for android and I am trying to get the duration of the songs (without a FileDiscriptor --> just with the path of the File) I am showing to sort them. But i get this exception when trying it:
java.lang.RuntimeException: setDataSource failed: status = 0x80000000
int column_index = songCursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
String songPath = songCursor.getString(column_index);
Uri u = Uri.parse(songPath);
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(getActivity().getApplicationContext() ,u);
String durationStr = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
int millSecond = Integer.parseInt(durationStr);
long dur = Long.parseLong("" + millSecond);
User contributions licensed under CC BY-SA 3.0