获得IOS7连接蓝牙耳机的作用 [英] Get the action of a connected bluetooth earphone in IOS7
问题描述
我怎样才能获得的操作按钮一样推入IOS7连接蓝牙耳机吗?
我想使用corebluetooth.framework,但它只能用于BLE装置,而没有对BLE耳机,我知道了。
那么,有没有我可以用做其他任何方法?或者是有可用于连接到非IOS设备的任何其他框架?
谢谢
How can I get the actions like button pushed of a connected bluetooth earphone in IOS7? I was thinking about using corebluetooth.framework,but it can only be used for BLE device while there is on BLE earphone as I know. So is there any other method I can use to do that?Or is there any other framework can be used to connect to a non-IOS device? Thanks
推荐答案
这是同样的方式与线控耳机。
It's same way with headphone wire.
一旦你应该得到控制的事件,添加以下在适当的位置code:
Once you should receive control events, add following code in proper position:
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
和删除接收事件,添加以下在适当的位置code:
And remove receive events, add following code in proper position:
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
RootViewController的或控制器只是接收事件应该加上:
RootViewController or the controller for just receive events should add:
- (BOOL)canBecomeFirstResponder {
return YES;
}
继code是做一下点击不同的按钮操作:
Following code is to do actions about clicking different buttons:
- (void)remoteControlReceivedWithEvent:(UIEvent *)event{
case UIEventSubtypeRemoteControlTogglePlayPause:
break;
case UIEventSubtypeRemoteControlPlay:
break;
case UIEventSubtypeRemoteControlPause:
break;
default:
break;
}
}
下面是定义UIEventSubtype的
Here is define of 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,
};
这里是链接<一个href=\"https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/Remote-ControlEvents/Remote-ControlEvents.html\"相对=nofollow>远程控制活动的。
希望能帮助你。
And here is the link for Remote Control Events. Hope to help you.
这篇关于获得IOS7连接蓝牙耳机的作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!