Choose between built in mic and headset in iOS

南楼画角 提交于 2019-11-29 11:19:19

Warning: This answer applies to iOS6 only. It is not correct for iOS7 or later. See comments for details.

This is possible, but only with a side effect. Changing the input device also changes the output device. You will not be able to record through the internal mic and at the same time listend to your recording in realtime through the headset's headphones. That means that if you do not want to listen simultaneously to your recording through the headphones, there is a solution for you:

When having connected a headset (= combined headphones and mic), you can choose between two alternatives:

  • internal mic for input and speaker for output
  • headset's mic for input and headset's headphones for output

(You can not use a mixture of these.)

You choose one of the alternatives by setting the property kAudioSessionProperty_OverrideAudioRoute through the function AudioSessionSetProperty of the Audio Session Services API. The documentation of the property says:

If a headset is plugged in at the time you set this property’s value to kAudioSessionOverrideAudioRoute_Speaker, the system changes the audio routing for input as well as for output: input comes from the built-in microphone; output goes to the built-in speaker.

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