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

查看:40
本文介绍了在 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 个主题:Forcing iPhone Microphone as音频输入如果耳机使用内置麦克风已插入,但我想根据这种情况没有任何最终决定.

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天全站免登陆