AudioSessioninput从蓝牙输出线或扬声器

一旦build立了audio会话,以下代码允许蓝牙input。

UInt32 allowBluetoothInput = 1; AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof (allowBluetoothInput), &allowBluetoothInput); 

此代码看起来像只允许蓝牙input,但是这个代码也将audio输出路由到蓝牙设备(在蓝牙耳机的情况下)。 当input来自蓝牙设备时,我想将audio输出路由出或扬声器。 我只是想从蓝牙设备获得audioinput,我不想通过蓝牙输出audio。

这种行为是可能的吗?

作为iOS 5的这种行为是不可能的,引用苹果技术支持

蓝牙设备不是“插入”设备,因此任何其他audio路由必须由用户select,不能在代码中进行更改。 为此,您可以使用MPVolumeView的function,该function将有一个额外的路由小部件可​​查看,允许用户指定输出的路由。

Core Audio邮件列表中有一个关于此function的旧线程,但行为并没有改变:

http://lists.apple.com/archives/coreaudio-api/2009/Oct/msg00030.html

MPVolumeView参考:

http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPVolumeView_Class/Reference/Reference.html

但是,MPVolumeView不允许您独立路由input和输出。