I am trying to play an mp3 using the Media player class. When I hardcode the mp3 resource it works, however I would like the resource to come from a string instead of directly accessing it like R.raw.mp3name
.
Bundle bundle = getIntent().getExtras();
String Choice= bundle.getString("bundledChoice");
Uri myUri = Uri.parse("R.raw." + Choice);
mPlayer = MediaPlayer.create(activity.this, myUri);
mPlayer.start();
If I change the second to last line to mPlayer = MediaPlayer.create(activity.this, R.raw.song)
it will work, the problem is creating the resource URI dynamically from the string which is obtained from the bundle.
Please advise.