我工作的机器人。如何录制可通过麦克风音频文件,以及如何保存录音文件中的模拟器?
I am working in android. How can I record an audio file through microphone, and how can I save the recorded file in the emulator?
这是很容易录制音频的机器人。 什么,你需要做的是:
It is easy to record audio in android. What you need to do is :
1)创建介质记录类对象:MediaRecorder记录=新MediaRecorder(); 2)在模拟器中,你无法保存记录的数据在内存中,所以你必须将其存储在SD卡。对于SD卡的可用性因此,首先检查:然后开始录制
1) Create the object for media record class : MediaRecorder recorder = new MediaRecorder(); 2) In the emulator, you're unable to store the recorded data in memory, so you have to store it on the sdcard. So first check for the SD Card availability:then start recording
String status = Environment.getExternalStorageState();
if(status.equals("mounted")){
String path = your path;
}
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
3) 要停止,活动覆盖停止方法
3) To stop, override stop method of activity
recorder.stop();
recorder.release();