在 iOS 中的内置麦克风和耳机之间进行选择 [英] Choose between built in mic and headset in iOS

查看:30
本文介绍了在 iOS 中的内置麦克风和耳机之间进行选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个需要在 iOS 中更改音频路由的应用.我们需要从麦克风输入中获取一些信息,然后换成设备的内部麦克风来录制环境声音.

We are developing an app that needs to change the audio route in iOS. We need to get some information from the mic input and then change to the internal mic of the device to record ambient sound.

我们从这些页面中看到了 2 个主题:强制 iPhone 麦克风为音频输入使用内置麦克风如果耳机已插入,但我想根据这种情况没有任何最终决定.

We have seen 2 topics from these pages: Forcing iPhone Microphone as Audio Input and Use built-in mic if Headset is plugged in but i guess there isn't any final word according to this situation.

现在,代码可以工作了,但我们可以选择音频输入的路径.

Now, the code works but we can select the route of the audio input.

我们没有在 Apple (Remote IO) 提供的文档中找到任何内容.

We haven't found anything in the documentation provided by Apple (Remote IO).

这有什么新的吗?

谢谢!

推荐答案

警告:此答案仅适用于 iOS6.对于 iOS7 或更高版本不正确.详情见评论.

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:

  • 用于输入的内置麦克风和用于输出的扬声器
  • 耳机麦克风用于输入,耳机耳机用于输出

(你不能混合使用这些.)

(You can not use a mixture of these.)

您可以通过设置属性 kAudioSessionProperty_OverrideAudioRoute 通过函数 AudioSessionSetProperty.该物业的文件说:

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:

如果在您设置此属性的值时插入了耳机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.

这篇关于在 iOS 中的内置麦克风和耳机之间进行选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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