Hello, how are you? I am trying to make a button of sounds in Android Studio and I put two buttons "btn1" and "personasjitos" (I leave the code below) when trying the application any of the two buttons I played the same file, Android Studio I do not mark any error in the code so I do not know what the problem may be, thank you very much for your answers.
public class MainActivity extends AppCompatActivity {
MediaPlayer mp;
Button btn1;
Button personajitos;
@SuppressLint("WrongViewCast")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1 = (Button) findViewById(R.id.button1);
personajitos = (Button) findViewById(R.id.personajitos);
mp = MediaPlayer.create(this, R.raw.peroperopero);
mp = MediaPlayer.create(this, R.raw.unospersonajitos);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mp.start();
}
});
personajitos.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mp.start();
}
});
}
}