AVAudioSession : microphone headphone as input and iphone speaker as output

两盒软妹~` 提交于 2019-12-07 09:59:15

问题


With iOS10 there are more possibilities to manage AUdioSession, but i couldn't manage to keep the headphone microphone as input while audio is going out through the iphone speaker.

The 'overrideOutputAudioPort' method below also override the input audio port as the iphone microphone

let session = AVAudioSession.sharedInstance()
do {
  try session.setCategory(AVAudioSessionCategoryPlayAndRecord)
  try! session.overrideOutputAudioPort(.speaker)  
} catch {
}

Is there any solution to keep the headphone as input?


回答1:


How I undeerstand this Apple documentation, this is not possible using AVAudioSession:

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.



来源:https://stackoverflow.com/questions/41487905/avaudiosession-microphone-headphone-as-input-and-iphone-speaker-as-output

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