java android play sound file with variable code example
Example 1: java android play sound file with variable
private void playMp3(String nameOfFile){
MediaPlayer mPlayer = MediaPlayer.create(this, getResources().getIdentifier(nameOfFile, "raw", getPackageName()));
mPlayer.start();
}
Example 2: java android play sound file with variable
private void playMp3(String nameOfFile){
MediaPlayer mPlayer = MediaPlayer.create(this, getResources().getIdentifier(nameOfFile, "raw", getPackageName()));
mPlayer.start();
}