如何记录在Android的音频文件 [英] How to record audio file in Android

查看:137
本文介绍了如何记录在Android的音频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的机器人。如何录制可通过麦克风音频文件,以及如何保存录音文件中的模拟器?

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();

这篇关于如何记录在Android的音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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