MediaPlayer prepare Failed Error(1,-17) when using recorded file .3gp

后端 未结 1 1210
借酒劲吻你
借酒劲吻你 2021-01-24 11:22

I am trying record from the AudioRecorder then I am trying to play the same with Media Player, But its giving mediaplayer.prepare() failed to prepare. Could any one tell me what

相关标签:
1条回答
  • 2021-01-24 12:20

    Implement the OnCompletionListener and register it with your MediaPlayer instance.

    After the media has been played out it will call this callback method onCompletion

    void onCompletion(MediaPlayer mp){
       //Here you stop it.
       mp.stop();
       //Reset the data source path to the new file
       mp.setDataSource(<uri>);
       mp.prepare(); // or mp.prepareAsync();
       // start the mediaplayer after the prepare has completed.
    }
    

    Release the mediaplayer instance once you are done playing all the files.

    0 讨论(0)
提交回复
热议问题