aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-10-07 06:21:58 +0200
committerTeddy Wing2018-10-07 06:21:58 +0200
commita4640221186905db82e3d9e71c5d28e6f6bf2b5e (patch)
treef16ecbfc0fd64cee6dfce4913ca873a13f6cb27e
parentda03d2650a6240ef1364bce789f72cc48cb75807 (diff)
downloadDomeKey-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.m1
-rw-r--r--DomeKey/HeadphoneKey.h2
-rw-r--r--DomeKey/HeadphoneKey.m19
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];