I am trying to play a sound file on the click of a button. The sound is just 1 sec long. It plays well the first few times I click the button, but after a while it gives a <
You can also try:
final soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0); final sound = soundPool.load(this, R.raw.mysound, 1); button[i].setOnClickListener(new OnClickListener() { public void onClick(View view) { soundPool.play(sound, 1.0f, 1.0f, 0, 0, 1.0f); } });