I upgraded my old nexus device to the latest and now MediaPlayer wont play custom ringtone paths that im retrieving by way of the ringtoneManager picker.
i have two media's as an example:
- content://media/internal/audio/media/86 --this one does not play, its a custom ringtone ( a mp3 i downloaded and added to /media/audio/ringtones/)
and
- content://media/internal/audio/media/54 --this one plays
im trying to play both with the mediaplayer API in android. Both media paths were returned to me by the RingtoneManager as follows:
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
// activity stack history, its a one time deal only
// intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE,
"Please Select A Ringtone");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALL);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
//intent.putExtra(RingtoneManager.EXTRA_RINGTONE_INCLUDE_DRM, true);
try {// 44 arbitrary number to recognize our intent
startActivityForResult(intent, 44);
}
//etc
and here is how i retrieve the selected ringtone. Everything works except when the user picks a custom ringtone from the list, i get a mediaplayer IO exception that the data resource cannot be played.
// find out what ringtone the user selected and play the tone.
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Ringtone ringtone;
if (requestCode == 44 && resultCode == RESULT_OK) {
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
}
//the uri is retrieved and its value is: content://media/internal/audio/media/86
here is the mediaplayer error i receive when i try ti play this custom ringtone :
e = {java.io.IOException@4499} "java.io.IOException: setDataSource failed.: status=0x80000000"
cause = {java.io.IOException@4499} "java.io.IOException: setDataSource failed.: status=0x80000000"
detailMessage = {java.lang.String@4503} "setDataSource failed.: status=0x80000000"
any other media works fine just not custom ringtones.