Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVAudioSession : microphone headphone as input and iphone speaker as output

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?

like image 573
Damien Romito Avatar asked Nov 09 '22 03:11

Damien Romito


1 Answers

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.

like image 72
shallowThought Avatar answered Nov 29 '22 12:11

shallowThought