在IOS7中获取连接的蓝牙耳机的动作

如何才能在IOS7中获得连接蓝牙耳机按钮的操作? 我正在考虑使用corebluetooth.framework,但它只能用于BLE设备,而我知道有BLE耳机。 那么我可以使用任何其他方法来做到这一点吗?或者是否有任何其他框架可用于连接到非IOS设备? 谢谢

它与耳机线相同。

收到控制事件后,请在适当的位置添加以下代码:

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; 

并删除接收事件,在适当的位置添加以下代码:

 [[UIApplication sharedApplication] endReceivingRemoteControlEvents]; 

RootViewController或仅用于接收事件的控制器应添加:

 - (BOOL)canBecomeFirstResponder { return YES; } 

以下代码是关于单击不同按钮的操作:

 - (void)remoteControlReceivedWithEvent:(UIEvent *)event{ case UIEventSubtypeRemoteControlTogglePlayPause: break; case UIEventSubtypeRemoteControlPlay: break; case UIEventSubtypeRemoteControlPause: break; default: break; } } 

这是UIEventSubtype的定义

 typedef NS_ENUM(NSInteger, UIEventSubtype) { // available in iPhone OS 3.0 UIEventSubtypeNone = 0, // for UIEventTypeMotion, available in iPhone OS 3.0 UIEventSubtypeMotionShake = 1, // for UIEventTypeRemoteControl, available in iOS 4.0 UIEventSubtypeRemoteControlPlay = 100, UIEventSubtypeRemoteControlPause = 101, UIEventSubtypeRemoteControlStop = 102, UIEventSubtypeRemoteControlTogglePlayPause = 103, UIEventSubtypeRemoteControlNextTrack = 104, UIEventSubtypeRemoteControlPreviousTrack = 105, UIEventSubtypeRemoteControlBeginSeekingBackward = 106, UIEventSubtypeRemoteControlEndSeekingBackward = 107, UIEventSubtypeRemoteControlBeginSeekingForward = 108, UIEventSubtypeRemoteControlEndSeekingForward = 109, }; 

这是远程控制事件的链接。 希望能帮到你。

在我的研究中,有些人通过“remoteControlReceivedWithEvent”从他们的bleu-tooth设备接收了一些事件,但并非全部! 有些人没有收到! 很少有人收到所有这些!

我也尝试过Core Bluetooth,但它只支持LEB(低功耗蓝牙设备)! https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothOverview/CoreBluetoothOverview.html#//apple_ref/doc/uid/TP40013257-CH2-SW1

此外,一些post建议可以使用Classic bleutooth而不是“Low Energy”: 如何使用蓝牙经典而不是le但它也有限制(post正在拍摄“MFi配件”!MFi是用于“制作”对于iPhone“?!?!?!)

从上面的post:“非LE蓝牙设备需要获得MFi批准才能与外部附件框架一起使用(它需要使用特定的Apple芯片和专有通信协议)。您将无法构建应用程序访问此设备,除非它使用更开放的蓝牙LE或其中有此芯片用于标准蓝牙。可能有办法通过越狱来做到这一点,但我知道的几乎每个人都转移到蓝牙LE。 !

更多post: 从iOS连接到蓝牙设备,没有MFi

问候。