AVAudioSession:麦克风耳机作为输入,iPhone扬声器作为输出 [英] AVAudioSession : microphone headphone as input and iphone speaker as output

查看:494
本文介绍了AVAudioSession:麦克风耳机作为输入,iPhone扬声器作为输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有了iOS10,就有更多的可能性来管理AUdioSession,但是当音频通过iPhone扬声器传出时,我无法保持耳机麦克风作为输入.

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.

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

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?

推荐答案

我如何理解此Apple文档,无法使用AVAudioSession:

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

如果您在将此属性的值设置为kAudioSessionOverrideAudioRoute_Speaker时插入了头戴式耳机,则系统会更改输入和输出的音频路由:输入来自内置麦克风;输出到内置扬声器.

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.

这篇关于AVAudioSession:麦克风耳机作为输入,iPhone扬声器作为输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆