Recording audio from external source in an android application

六月ゝ 毕业季﹏ 提交于 2019-12-08 08:52:37

问题


I saw there was a similar question here: Is it possible to record from the external mic when recording video in Android?

However, the question was never really answered and android documentation does not clearly state how this is done.

This person in this thread states that it is possible, but does not say how. Real-time audio capture and playback from an external mic

It would make sense for you to make the selection in the "setAudioSource" section, but none of the options are for external sources.

MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.VOICE_DOWNLINK);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

I am stuck with my app being 99% done. Any help would be greatly appreciated.


回答1:


Is the external mic detected as a wired headset? If not, I don't think this is going to work. There's no such audio device as a "wired external microphone" in vanilla Android.

If it is detected as a wired headset it should be working out of the box if you use the MIC or DEFAULT AudioSource when recording. If it doesn't I'd say that's a flaw in the version of Android that you've got on your phone.




回答2:


In my testing of USB Audio products, the MIC, DEFAULT, and VOICE_COMMUNICATION sources all switch to a USB Audio mic if it's connected. The CAMCORDER source always uses the built-in mic. I can't find any clear documentation of this, though. This page doesn't mention external/USB audio at all.



来源:https://stackoverflow.com/questions/16948769/recording-audio-from-external-source-in-an-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!