I have URI of the notification sound, like content://media/internal/audio/media/122
, but SoundPool
doesn\'t work with URIs, it works with only apk
Inspired by Dmitry's answer.
One line can solved the problem.
Well, I got the easiest way to play audio by URI:
RingtoneManager.getRingtone(this, Uri.parse("content://media/internal/audio/media/122")).play();
I think this is the best what i could achieve.
Try this to get a full path:
String path = Environment.getRootDirectory().getAbsolutePath(); //Will return "/system"
path = path + Uri.getPath().subString(9); //To cut "content:/" from the Uri path.
//Then pass this "path" to your SoundPool
You are right. Unlike MediaPlayer which is used for music and videos, SoundPool is meant to be used for short app audio resources like notifications. It is much faster and lighter than MediaPlayer.