swift – AVAudioSession:麦克风耳机作为输入,iphone扬声器作为输出

使用iOS10,管理AUdioSession的可能性更大,但是当音频通过
iphone扬声器输出时,我无法将耳机麦克风作为输入.

下面的’overrideOutputAudioPort’方法也会将输入音频端口覆盖为iphone麦克风

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

是否有任何解决方案可以保持耳机输入?

最佳答案 我如何解析
this Apple documentation,使用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.

点赞