diff options
author | Teddy Wing | 2018-10-07 06:21:58 +0200 |
---|---|---|
committer | Teddy Wing | 2018-10-07 06:21:58 +0200 |
commit | a4640221186905db82e3d9e71c5d28e6f6bf2b5e (patch) | |
tree | f16ecbfc0fd64cee6dfce4913ca873a13f6cb27e | |
parent | da03d2650a6240ef1364bce789f72cc48cb75807 (diff) | |
download | DomeKey-a4640221186905db82e3d9e71c5d28e6f6bf2b5e.tar.bz2 |
HeadphoneKey: Try using `MPRemoteCommandCenter` to listen for media keys
Try to use `MPRemoteCommandCenter` to get Bluetooth button input.
Doesn't appear to work.
-rw-r--r-- | DomeKey/AppDelegate.m | 1 | ||||
-rw-r--r-- | DomeKey/HeadphoneKey.h | 2 | ||||
-rw-r--r-- | DomeKey/HeadphoneKey.m | 19 |
3 files changed, 22 insertions, 0 deletions
diff --git a/DomeKey/AppDelegate.m b/DomeKey/AppDelegate.m index 318aeee..fab5171 100644 --- a/DomeKey/AppDelegate.m +++ b/DomeKey/AppDelegate.m @@ -14,6 +14,7 @@ { _headphone_key = [[HeadphoneKey alloc] init]; [_headphone_key startMonitoringBluetoothEvents]; + [_headphone_key mpmediaplayerBS]; } @end diff --git a/DomeKey/HeadphoneKey.h b/DomeKey/HeadphoneKey.h index 586c40b..61c4864 100644 --- a/DomeKey/HeadphoneKey.h +++ b/DomeKey/HeadphoneKey.h @@ -7,6 +7,7 @@ // #import <Foundation/Foundation.h> +#import <MediaPlayer/MediaPlayer.h> #import <DDHidLib/DDHidAppleMikey.h> #import "dome_key_map.h" @@ -30,5 +31,6 @@ static const unsigned int TIMEOUT_MILLISECONDS = 1000; - (void)handleDeadKey:(HeadphoneButton)button; - (void)runAction; - (void)startMonitoringBluetoothEvents; +- (void)mpmediaplayerBS; @end diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m index 5a062fc..e1588eb 100644 --- a/DomeKey/HeadphoneKey.m +++ b/DomeKey/HeadphoneKey.m @@ -96,6 +96,25 @@ }]; } +- (void)mpmediaplayerBS +{ + MPRemoteCommandCenter *center = [MPRemoteCommandCenter sharedCommandCenter]; + + [[center togglePlayPauseCommand] addTarget:self action:@selector(mpmediaplayerplaypauesss:)]; +// pauseCommand +// playCommand +// togglePlayPauseCommand +// nextTrackCommand +// previousTrackCommand +} + +- (MPRemoteCommandHandlerStatus) mpmediaplayerplaypauesss: (MPRemoteCommandEvent*) event +{ + NSLog(@"Played from MPMediaPlayer"); + + return MPRemoteCommandHandlerStatusSuccess; +} + - (void)handleDeadKey:(HeadphoneButton)button { NSNumber *storable_button = [NSNumber numberWithUnsignedInteger:button]; |