I'm trying to pause a recording on an incoming call and resume it later. i'm using the andriod mediarecorder
and trying to record in MPEG4
. I tried pause/resume with resetting/stopping a recording and starting it with the setOutputFile(fd)
, fd
being the filedescriptor
of the audio file that was stopped/paused and hoped it would append but i had no luck. Is there a way to achieve this or append two recordings or should i give up on mediarecorder
.
code:
private MediaRecorder media_recorder;
private String file_path = null;
public void startRecording(path)
{
file_path = path
media_recorder= new MediaRecorder();
media_recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
media_recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
media_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
media_recorder.setOputputFile(path);
media_recorder.prepare();
}
public void pauseRecording()
{
media_recorder.stop();
media_recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
media_recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
media_recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
FileOutputStream paused_file = new FileOutputStream(file_path);
media_recorder.setOutputFile(paused_file.getFD());
}
public void resumeRecording()
{
media_recorder.prepare();
media_recorder.start();
}
pauseRecording()
stops the recording but resume fails with message start failed
.