Unsure about Audio!

Put your problem here if it does not fit any of the other categories.

Unsure about Audio!

Postby ramgraph1 » Thu Mar 06, 2008 11:50 pm

I seem to have a lot of struggles with audio.
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.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
           public void onCompletion(MediaPlayer buttonclick){          

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.
Experienced Developer
Experienced Developer
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 4 guests