The name says it.
My application plays ringtones that uri points to, for example content://media/internal/audio/media/387 or content://media/external/audio/media/1655 (for custom tunes on an SDcard, which I suppose ) using both setDataSource(fileInfo) and setDataSource(mContext, Uri.parse(fileInfo)) .
In each case, I received logs with setDataSource failed.: status=0x80000000 exception setDataSource failed.: status=0x80000000 on phones using Android 4.x (different versions).
Having seen that the error only occurs with the ringtones specified in the uri content, but not with the single files specified in the path, I decided to use also the paths for the ringtones that fixed the problem on the above phones (when using setDataSource(mContext, Uri.parse(fileInfo)) )
However, he was having problems with phones with Android 2.3.4-2.3.6 (not on my 2.3.3):
- I received several logs with the exception:
setDataSource failed.: status=0x80000000 for files with paths such as /system/media/audio/ringtones/TwirlAway.ogg I also got a log about calling the MediaPlayer.onErrorListener.onError(int what, int extra) method with what=1 and extra=-2147483648 , which, as I know, suggests either this file is missing or damaged. However i do
File file = new File(fileInfo); if (!file.exists())
check in this situation, and he returned that the file exists - is it damaged? Very unlikely for a music file in internal memory.
Summarizing:
- works with
setDataSource("content://media/internal/audio/media/52") setDataSource failed.: status=0x80000000 exception: setDataSource failed.: status=0x80000000 for setDataSource(mContext, "/system/media/audio/ringtones/TwirlAway.ogg")
Interestingly, the first few lines of the setDataSource(Context context, Uri uri, Headers headers) method setDataSource(Context context, Uri uri, Headers headers) , which is called setDataSource(Context context, Uri uri) , are ( from GrepCode source for 2.3.4 ):
String scheme = uri.getScheme(); if(scheme == null || scheme.equals("file")) { setDataSource(uri.getPath()); return; }
So, in the end, it just fails for setDataSource("/system/media/audio/ringtones/TwirlAway.ogg") . I took the paths to ringtones from uris using:
private static String getRingtonePathFromContentUri(Context context, Uri contentUri) { String[] proj = { MediaStore.Audio.Media.DATA }; Cursor ringtoneCursor = context.getContentResolver().query(contentUri, proj, null, null, null); ringtoneCursor.moveToFirst(); return ringtoneCursor.getString(ringtoneCursor .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)); }
Any ideas that might throw error throwing? Perhaps these are some problems caused by a lack of read permissions? I think the source code for the setDataSource (String path) built-in function would help a lot, but I could not find it.