1
E/MediaPlayer(20473): error (-19, 0)

I/MyApp   (20473): Decoding lala.mp3

I/StagefrightPlayer(   68): setDataSource('mypath')

E/AudioFlinger(   68): no more track names available

E/AudioTrack(   68): AudioFlinger could not create track, status: -12

E/AudioSink(   68): Unable to create audio track

Does any1 know why i'm getting this? This usually happens after playing about 100+ of so audio files using mediaPLayer. I'm playing it like this

public RenderResultFormat DoIt() {
   if(mp!=null){
         mp.release();
         mp = null;
     }
AudioRenderer mr = new AudioRenderer(); mp = mr.AudioRenderer(filePath);}   



private class AudioRenderer extends Activity {
    private MediaPlayer AudioRenderer(String filePath) {
//delcare mediaplayer variables, path etc
  mp= MediaPlayer.create(this, path);
 if(mp != null){  
   int duration = mp.getDuration();
                mp.start();
                try {
                    Thread.sleep(duration);
                } catch (InterruptedException e2) {
                    e2.printStackTrace();
                    System.out.println("I've been interrupted >:(");
                }
                }
}return mp;}

Am i missing something? Quite new to android development. Thank you

RzR
  • 3,068
  • 29
  • 26
Sith
  • 105
  • 1
  • 4
  • 11
  • Do you `release` mp after usage, as recommended in the doc? (http://developer.android.com/reference/android/media/MediaPlayer.html#release()) – Joubarc Aug 23 '11 at 07:47
  • thanks i'll have a look on that. Yes i did release but i didn't know you need to declare mp=null again after you release. Ill try it out – Sith Aug 23 '11 at 07:53

1 Answers1

3

This solution works well for me (playing a ressource). Just implement an OnCompletionListener

private void playbeep(int id) {

    MediaPlayer mPlayer;
    mPlayer = MediaPlayer.create(context, id);
    mPlayer.start();
    mPlayer.setOnCompletionListener(new OnCompletionListener() {        
        public void onCompletion(MediaPlayer mp) {
            mp.release();
        }
    });
}
jsnoob
  • 76
  • 1
  • 6