Android 中的暂停和恢复录音
我正在使用 MediaRecorder 类在 Android 2.3 中开发音频录制应用程序。我有以下要求:
- 当发生中断时,例如在通话录音期间,暂停录音。
- 中断结束并调用录制活动的 onResume 后,我必须从暂停的位置恢复录制。
我找不到 MediaRecorder api 来暂停和恢复录制。只有 start() 和 stop() 可用。
除了在中断前后记录两个单独的文件然后将它们合并成一个文件之外,还有其他方法可以实现这一目的吗?
斯内哈·约翰.
I am developing an audio recording application in Android 2.3 using MediaRecorder class. I have the following requirement :
- When an interruption occurs , say during recording a call , pause recording .
- After the interruption is over and onResume of my recording activity is called , I have to resume recording from the point where it was paused .
I could not find a MediaRecorder api to pause and resume recording. Only start() and stop() are available.
Apart from recording two separate files before and after interruption and then joining them together into one file, is there any other way to achieve this?
Sneha John.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种可能的方法来完成此任务,如果您使用媒体录音机进行录音,则可以将一个音频文件附加到另一个音频文件中,就像当您接到来电时,会自动调用暂停并在您的 onPause 上() 您可以记录第一个文件,当您再次返回活动时,您可以记录一个临时
fileResume()
并将该临时文件附加到前一个文件中。另一种方法是使用
AudioRecorder()
类。您可以将音频录制为原始文件并根据您的要求附加这些文件,最后当您想要停止录制时,可以将标头添加到该原始文件中并将其转换为您想要的音频格式。There are two possible ways to do this task, if u are using media recorder for the recording than you can append one audio file into another, Like when you got a incoming call than automatically your on pause is called and on your
onPause()
you can recorde that 1st file, when you comes back again on your activity than you can record a temporaryfileResume()
and append this temporary file into the previous one.And another way is using
AudioRecorder()
class. In that you can record audio as raw file and append those files as per your requirement and finally when you want to stop the recording than add a header into that raw file and convert that into your desired audio format.