使用Mediaplayer时出错-19,0?

时间:2011-08-23 07:40:59

标签: android media-player android-mediaplayer alsa

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

有没有人知道我为什么会这样做?这通常发生在使用mediaPLayer播放大约100个以上的音频文件之后。我正在玩这个

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;}

我错过了什么吗? Android开发的新手。谢谢

1 个答案:

答案 0 :(得分:3)

此解决方案适用于我(播放资源)。只需实施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();
        }
    });
}