我正在构建可以录制音频的应用程序。但是我不知道如何在设备上选择顶部或底部麦克风。
我阅读了https://developer.android.com/上的文档,并且知道我们可以使用 MediaRecorder类来录制音频,它具有2个定义MIC和CAMCORDER。
如果我们使用MIC定义,那么电话将使用底部麦克风
否则我们将使用CAMCORDER,然后手机将使用顶级麦克风。那正确吗?
mFileName = FunctionIndex.PATH + "/" + this.functionKey +".3gp";
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioChannels(1);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
MyLog.e("Microphone prepare() failed" + e.getMessage().toString());
}
mRecorder.start();
最佳答案
这是我的代码
mFileName = FunctionIndex.PATH + "/" + this.functionKey +".3gp";
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioChannels(1);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
MyLog.e("Microphone prepare() failed" + e.getMessage().toString());
}
mRecorder.start();
和MIC&CAMCORDER有什么不同?
关于android - Android上的顶部麦克风和底部麦克风如何选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52417298/