audio_session
audio_session copied to clipboard
[Question] Is it possible to select the input microphone on Android?
I am investigating the possibilities of selecting the input port/audio source/microphone for recordings being done on the device. Ideally these can be selected independently from the audio output. A use case would be to play audio to wired headphones, while simultaneously recording audio from the device-internal microphone.
iOS
I have succeeded in doing so on iOS by using the setPreferredInput() function of AVAudioSession, in combination with the availableInputs getter. In case anybody is interested, check this.
Since setPreferredInput() is marked as "UNTESTED" in the package I can hereby report that it actually works well. 🙂
Android
I believe on Android this might be achievable via setAudioSource() on MediaRecorder. An alternative might be setPreferredDevice() with AudioRecord.
However, I am not sure this is the right path... Also, none of those interfaces is available in audio_session (yet?).
Does anybody have experience in achieving this on Android?
Thanks!
Hi @toebgen I would suggest asking on StackOverflow so that you can ask a wider audience of Android programmers. audio_session is after all a direct wrapper around the Android APIs
Thanks @ryanheise, I will do that.
Nevertheless, do you plan to add the mentioned MediaRecorder and/or AudioRecord APIs in audio_session as well?
I don't think MediaRecorder or AudioRecord are related to the audio session and should more appropriately be handled by a separate plugin specifically for recording. There are other packages on pub.dev that focus on recording, so either a feature request could be submitted to those projects or someone could created a new plugin of their own.
Thanks for your fast response. For future reference, here is the SO question: https://stackoverflow.com/questions/72649098/is-it-possible-to-select-the-input-microphone-on-android-flutter