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开发来说是相当新的。谢谢

最佳答案

该解决方案对我来说效果很好(播放资源)。只需实现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();
        }
    });
}

07-24 09:25