我正在尝试暂停来电的录音并稍后恢复。我正在使用andriod mediarecorder
并尝试在MPEG4
中录制。我尝试暂停/恢复重置/停止录制,并使用setOutputFile(fd)
启动它,fd
是已停止/暂停的音频文件的filedescriptor
,希望它会附加但是我没有运气。有没有办法实现这个或附加两个录音,或者我应该放弃mediarecorder
。
码
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()
停止录制,但恢复失败并显示消息start failed
。
答案 0 :(得分:3)
您的问题的简单答案是不,你不能
Once you are recording the only possible actions are stop and reset.
因此,请在停止后尝试将呼叫保存到SDCard,然后再次启动Fresh Record并将其停止。 Finally Combine both Audio File into one Audio file
。
将音频录制为.wav文件和Combine using this format。