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

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

问题描述

我们正在开发一个需要改变的iOS音频路由的应用程序。我们需要从麦克风输入得到一些信息,然后切换到该设备的内置麦克风录制周围的声音。

我们已经看到2主题从这些页面:<一href=\"http://stackoverflow.com/questions/4002133/forcing-iphone-microphone-as-audio-input/13347637#13347637\">Forcing iPhone麦克风的音频输入和使用内置麦克风耳机是否插入了但我想没有按照这种情况的最后一句话。

现在,code ++工程,但我们可以选择音频输入的路径。

苹果(远程IO)。

提供的文档中

我们还没有发现任何东西

有什么新的这个呢?

谢谢!


解决方案

警告:这个答案只适用于iOS6的。它不是iOS7正确。看评论的详细信息。

这是可能的,但只用一个副作用。变更输入装置也改变输出设备。您将无法通过内置麦克风,并在通过耳机的耳机listend您的录音实时同一时间录制。这意味着,如果你不希望同时收听通过耳机您的录音,有你的解决方案:

当有连接的耳机(=合并耳机和麦克风),你可以两种方案之间进行选择:


  • 输入和扬声器输出内置麦克风

  • 耳机的麦克风输入和耳机的耳机输出

(不能使用它们的混合物)。

您通过设置属性<一个选择方案之一href=\"http://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html#//apple_ref/c/econst/kAudioSessionProperty_OverrideAudioRoute\"相对=nofollow> kAudioSessionProperty_OverrideAudioRoute 通过函数<一个href=\"http://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html#//apple_ref/c/func/AudioSessionSetProperty\"相对=nofollow> AudioSessionSetProperty音频会议服务API的。该物业的文件说:


  

如果一个耳机的时候插入设置该属性的值
  到 kAudioSessionOverrideAudioRoute_Speaker ,该系统改变了
  输入以及用于输出音频路由:输入来自
  内置麦克风;输出到内置扬声器。


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.

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.

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

Is there anything new about this?

Thanks!

解决方案

Warning: This answer applies to iOS6 only. It is not correct for iOS7. 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:

  • internal mic for input and speaker for output
  • headset's mic for input and headset's headphones for output

(You can not use a mixture of these.)

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:

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