开发者

error -19,0 from using Mediaplayer?

开发者 https://www.devze.com 2023-03-29 19:59 出处:网络
E/MediaPlayer(20473): error (-19, 0) I/MyApp(20473): Decoding lala.mp3 I/StagefrightPlayer(68): setDataSource(\'mypath\')
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


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();
        }
    });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消