Mediaplayer + Audioflinger problem

All your problems with Audio, Video and Images.

Mediaplayer + Audioflinger problem

Postby Grendizer » Sat Mar 05, 2011 3:15 pm

Hi all

I have a dialpad that contains imagebuttons, and when ever a button is clicked a sound is played.
So if number one is pressed a file will be played saying "One". For this purpose i'm using mediaplayer.
The thing is if I press a button multiple times, I'll get an error saying the following:
AudiotTrack: AudioFlinger could not create track, status: -12
AudioSink: Unable to create audio track
Mediaplayer: error(-19, 0)
Mediaplayer: Error(-19, 0).

For each onclick event i send the mediaplayer and the file to a method...here's an example:

Button nr. 1
Code: Select all
ImageButton one = (ImageButton) findViewById(R.id.btnOne);
      one.setOnClickListener(new OnClickListener() {
         public void onClick(View v) {
            playSound(mp, R.raw.mamacita_one);            
         }
      });


Method for playing sound:
Code: Select all
private void playSound(MediaPlayer mp, int tone) {
      if(mp != null) {
         mp.stop();
         mp.reset();
         mp.release();
         mp = null;
      }
      mp = MediaPlayer.create(this.getApplicationContext(), tone);
      mp.start();            
   }


I'd appreciate any help here...
Grendizer
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sun Mar 14, 2010 5:14 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Google [Bot] and 10 guests