I WAS creating a MediaPlayer in onCreate and then playing it each time the user clicked a button and using ".reset" to try to get it to play again but it wouldn't play more than once. I moved the create MediaPlayer to a function that is called on each button click. Like this:
- Code: Select all
public void playbuttonclick(){
buttonclick = MediaPlayer.create(this,R.raw.click);
buttonclick.start();
buttonclick.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer buttonclick){
buttonclick.release();
}});
}
It plays the sound after each click now but the app crashes after clicking the buttons more than a dozen or so times. If I use buttonclick.reset it crashes even more quickly. So I can't create the MediaPlayer one time and use it again and again (it won't play more than once) AND I can't create it many times (it crashes the app).
I know I must be doing something wrong. What is it? Any ideas? Thanks.

