I want to detect when play/pause music button is pressed in a bluetooth keyboard connected to the ipad. The keyboard is "ACTECK FT-850".
I'm using this method to detect other buttons.
-(NSArray * ) keyCommands
{
if ([[[UIDevice currentDevice] systemVersion] intValue] !=7) return nil;
UIKeyCommand *Letter = [UIKeyCommand keyCommandWithInput: @"a" modifierFlags: 0 action: @selector(Letter:)];
UIKeyCommand *upArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputUpArrow modifierFlags: 0 action: @selector(upArrow:)];
return [[NSArray alloc] initWithObjects: upArrow, Letter,nil];
}
- (void) Letter: (UIKeyCommand *) keyCommand
{
NSLog(@"LETRA A");
}
- (void) upArrow: (UIKeyCommand *) keyCommand
{
NSLog("Do something");
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
It works perfectly, but I dont know what letter o command put in KeyCommandWithInput
for detect "Play/pause" music button,... I already try this too:
-(void)viewDidAppear:(BOOL)animated
{
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent
{
NSLog(@"ENTER TO REMOTE CONTROL");
if (theEvent.type == UIEventTypeRemoteControl) {
switch(theEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
NSLog(@"SE TOCO EL BOTON PLAY/PAUSE");
case UIEventSubtypeRemoteControlPlay:
NSLog(@"SE TOCO EL BOTON PLAY");
break;
default:
return;
}
}
}
But remoteControlReceivedWithEvent
never is called when I press the button.
Please help me.