How can I create a button with SoundEffect using the MediaPlayer class or any other android class?
I tried using the following code that I found some examples, but I did not succeed.
public void playMusic(){
if(player == null){
try {
player = MediaPlayer.create(TelaJogoSingle.this, R.raw.song1);
player.start();
}
catch (IllegalArgumentException e) { e.printStackTrace(); }
catch (SecurityException e) { e.printStackTrace(); }
catch (IllegalStateException e) { e.printStackTrace(); }
}else{
player.start();
}
}