The method setDataSource()
has several overloads, the one you are trying to use gets a path.
The method toString()
class Uri does not return a path but rather the representation, in string, of Uri with which it was built.
What you’re doing is the equivalent of this:
mediaPlayer.setDataSource("android.resource://" + ctx.getPackageName() + "/" + R.raw.file);
You’re not actually using Uri who built on the line:
Uri url = Uri.parse("android.resource://" + ctx.getPackageName() + "/" + R.raw.file);
You should therefore use the Overload of the method setDataSource()
who receives a Uri:
Uri url = Uri.parse("android.resource://" + ctx.getPackageName() + "/" + R.raw.file);
mediaPlayer.setDataSource(ctx, url);
You can explain better what you mean. I can’t understand your answer.
– ramaral