在 Android 中暂停和恢复录音 [英] Pause and Resume Audio recording in Android

查看:77
本文介绍了在 Android 中暂停和恢复录音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 MediaRecorder 类在 Android 2.3 中开发录音应用程序.我有以下要求:

I am developing an audio recording application in Android 2.3 using MediaRecorder class. I have the following requirement :

  1. 发生中断时,例如在通话录音期间,暂停录音.
  2. 在中断结束并调用我的录制活动的 onResume 后,我必须从暂停点继续录制.

我找不到用于暂停和恢复录制的 MediaRecorder api.只有 start() 和 stop() 可用.
除了在中断前后录制两个单独的文件,然后将它们合并为一个文件,还有其他方法可以实现吗?

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?

斯内哈·约翰.

推荐答案

有两种可能的方法来完成这项任务,如果你使用媒体录音机进行录音,那么你可以将一个音频文件附加到另一个文件中,就像当你得到来电会自动调用您的暂停,并且在您的 onPause() 上,您可以记录第一个文件,当您再次返回活动时,您可以记录临时 fileResume() 并将这个临时文件附加到前一个文件中.

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 temporary fileResume() and append this temporary file into the previous one.

另一种方法是使用 AudioRecorder() 类.因为您可以将音频录制为原始文件并根据您的要求附加这些文件,最后当您想要停止录制时,而不是在该原始文件中添加一个标题并将其转换为您想要的音频格式.

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.

这篇关于在 Android 中暂停和恢复录音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆