3

我正在尝试在我的 iPhone 上获取配对的蓝牙耳机设备列表。我尝试了如下外部附件框架:

[[EAAccessoryManager sharedAccessoryManager] registerForLocalNotifications];
NSArray *accessories = [[EAAccessoryManager sharedAccessoryManager] connectedAccessories];

但附件数组始终为空。我错过了什么?获取连接的蓝牙耳机列表的正确方法是什么?

假设我可以获得蓝牙耳机列表,有没有办法将音频输出重定向到某个蓝牙耳机?

根据下面的代码,无法选择将音频发送到哪个设备:

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

谢谢你的帮助,

迈赫达德

PS:我还尝试了Apple的示例应用程序,它实践了External Accessory Framework,没有运气!

4

2 回答 2

2

你有没有解决过这个问题?我是外部附件框架的新手,但从我发现这个框架只支持符合 MFi 的设备:http: //developer.apple.com/library/ios/#qa/qa1657/_index.html

于 2012-05-15T00:18:33.347 回答
0

为了解决这个问题,我使用AVAudioSeesionAVFoundation.framework以下代码并检查了可用的输入:

NSArray *availInputs = [[AVAudioSession sharedInstance] availableInputs];

如果您在新设备连接或断开连接时还需要通知,您可以注册观察者AVAudioSessionRouteChangeNotification(您必须打开 setup new AVAudioSession

请在此处查看我的完整答案: https ://stackoverflow.com/a/29367963/1787109

于 2015-04-06T08:24:16.693 回答