From 5aacae0d3ddab43ccb864033033d56e7a2d322f4 Mon Sep 17 00:00:00 2001 From: ulion Date: Mon, 28 Jan 2013 23:20:39 +0800 Subject: [PATCH] accept control from ios control bar (on lock screen and left of multi-task bar) --- xbmc/osx/ios/XBMCController.mm | 46 +++++++++++++++++++++++++++++++++++++++++ xbmc/osx/ios/XBMCIOS-Info.plist | 4 ++++ 2 files changed, 50 insertions(+) diff --git a/xbmc/osx/ios/XBMCController.mm b/xbmc/osx/ios/XBMCController.mm index 0417d62..6a04fcd 100644 --- a/xbmc/osx/ios/XBMCController.mm +++ b/xbmc/osx/ios/XBMCController.mm @@ -290,6 +290,7 @@ extern NSString* kBRScreenSaverDismissed; { [view removeFromSuperview]; m_glView.userInteractionEnabled = YES; + [self becomeFirstResponder]; } //-------------------------------------------------------------- -(void)handlePinch:(UIPinchGestureRecognizer*)sender @@ -601,6 +602,14 @@ extern NSString* kBRScreenSaverDismissed; [super viewWillAppear:animated]; } //-------------------------------------------------------------- +-(void) viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + + [self becomeFirstResponder]; + [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; +} +//-------------------------------------------------------------- - (void)viewWillDisappear:(BOOL)animated { PRINT_SIGNATURE(); @@ -613,8 +622,16 @@ extern NSString* kBRScreenSaverDismissed; [super viewWillDisappear:animated]; } //-------------------------------------------------------------- +- (BOOL) canBecomeFirstResponder +{ + return YES; +} +//-------------------------------------------------------------- - (void)viewDidUnload { + [[UIApplication sharedApplication] endReceivingRemoteControlEvents]; + [self resignFirstResponder]; + [super viewDidUnload]; } //-------------------------------------------------------------- @@ -709,6 +726,35 @@ extern NSString* kBRScreenSaverDismissed; m_window.screen = screen; } //-------------------------------------------------------------- +- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent { + LOG(@"%s: type %d, subtype: %d", __PRETTY_FUNCTION__, receivedEvent.type, receivedEvent.subtype); + if (receivedEvent.type == UIEventTypeRemoteControl) + { + switch (receivedEvent.subtype) + { + case UIEventSubtypeRemoteControlTogglePlayPause: + CApplicationMessenger::Get().SendAction(ACTION_PLAYER_PLAYPAUSE); + break; + case UIEventSubtypeRemoteControlPlay: + CApplicationMessenger::Get().SendAction(ACTION_PLAYER_PLAY); + break; + case UIEventSubtypeRemoteControlPause: + // ACTION_PAUSE sometimes cause unpause, use MediaPauseIfPlaying to make sure pause only + CApplicationMessenger::Get().MediaPauseIfPlaying(); + break; + case UIEventSubtypeRemoteControlNextTrack: + CApplicationMessenger::Get().SendAction(ACTION_NEXT_ITEM); + break; + case UIEventSubtypeRemoteControlPreviousTrack: + CApplicationMessenger::Get().SendAction(ACTION_PREV_ITEM); + break; + default: + LOG(@"unhandled subtype: %d", receivedEvent.subtype); + break; + } + } +} +//-------------------------------------------------------------- - (void)pauseAnimation { XBMC_Event newEvent; diff --git a/xbmc/osx/ios/XBMCIOS-Info.plist b/xbmc/osx/ios/XBMCIOS-Info.plist index 580f706..1b491c9 100644 --- a/xbmc/osx/ios/XBMCIOS-Info.plist +++ b/xbmc/osx/ios/XBMCIOS-Info.plist @@ -36,6 +36,10 @@ UIInterfaceOrientationLandscapeLeft UIPrerenderedIcon + UIBackgroundModes + + audio + UIRequiredDeviceCapabilities armv7 -- 2.7.4