安卓.如何通过音频流录制麦克风? [英] Android. How to record the microphone over audio stream?
本文介绍了安卓.如何通过音频流录制麦克风?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中播放音乐时,用户此时应说成麦克风.你能告诉我如何做记录吗?音乐和麦克风的顶部路径.我浏览了MediaRecorder,但我认为没有合适的记录源.
In my application playing music, the user should say at this time into the microphone. Can you please tell me how to make a record? Music and top path from the microphone. I looked through MediaRecorder, but there is not, in my opinion, an appropriate recording source.
推荐答案
通过麦克风录制
通过麦克风开始和停止录制....
Start and stop recording through Mic....
开始录制
static MediaRecorder recorder = new MediaRecorder();
static String path, filename, time;
static int duration;
public void startRecording() {
try {
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.RAW_AMR);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
System.currentTimeMillis();
filename = ListenCallState.number + "_" + time + ".amr";
File f = new File(getBaseURL());
f.mkdirs();
path = getBaseURL() + filename;
recorder.setOutputFile(path);
recorder.prepare();
recorder.start();
} catch (Exception {
}
}
停止记录
public static void stopRecording() {
recorder.stop();
recorder.release();
try {
MediaPlayer p = new MediaPlayer();
p.setDataSource(path);
p.prepare();
duration = p.getDuration();
} catch (Exception e) {
}
}
这篇关于安卓.如何通过音频流录制麦克风?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文