0
So I would like to know when my audio has reached the end of the playback, follow my code to startar the audio and stop, I thank you in advance!
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
uploadAudio();
}
Why don’t you use the Mediaplayer class to run the audio? So you can have a greater control over it! There is an event called onCompletion in this class!
– mcamara
Thanks Milton, I’m using the media player , I have onCompletion here, I didn’t know it was for this , for me it was called as soon as I started reading the file and not when it was finished, anyway . I’ll check here.
– Wallace Roberto
See if this snippet of code helps you! mplayer.setOnCompletionListener(new Mediaplayer.Oncompletionlistener() { public void onCompletion(Mediaplayer mp) { //TODO } });
– mcamara