如何暂停/恢复与mediarecorder创建的录制? [英] How to pause/resume a recording created with mediarecorder?
问题描述
我想暂停录制的来电,并在稍后继续。我使用的是安卓 mediarecorder
,并试图在 MPEG4
录制。我想暂停/带复位/停止记录,并与 setOutputFile(FD)启动它恢复
, FD
作为文件描述符
已停止/暂停,并希望它追加,但我有没有运气的音频文件。有没有办法实现这个或追加两个记录或者我应该放弃对 mediarecorder
。
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()
停止记录,但恢复失败,消息启动失败。
。
pauseRecording()
stops the recording but resume fails with message start failed
.
推荐答案
你的问题简单的答案是不,你不能
Simple answer for your question is NO YOU CAN'T
一旦你记录的唯一可能的操作是停止和复位。
所以尽量保存您的通话,以SD卡停止后,然后再次重新开始记录和停止它。 最后合并两组音频文件到一个音频文件
。
So try to save your Call to SDCard after you Stop , and then again start Fresh Record and Stop it. Finally Combine both Audio File into one Audio file
.
录制音频为.wav文件,结合使用此格式。
Record the audio as .wav file and Combine using this format.
这篇关于如何暂停/恢复与mediarecorder创建的录制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!