[vlc-commits] macosx: add support for shuffle and repeat to the remote control service

Felix Paul Kühne git at videolan.org
Fri Jun 8 20:45:47 CEST 2018


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri Jun  8 20:44:37 2018 +0200| [d5a6834382102b345d14e5b2acd28d3f78386902] | committer: Felix Paul Kühne

macosx: add support for shuffle and repeat to the remote control service

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d5a6834382102b345d14e5b2acd28d3f78386902
---

 modules/gui/macosx/VLCInputManager.m         |  2 ++
 modules/gui/macosx/VLCRemoteControlService.m | 27 ++++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/modules/gui/macosx/VLCInputManager.m b/modules/gui/macosx/VLCInputManager.m
index db8d9a3008..cdc8409401 100644
--- a/modules/gui/macosx/VLCInputManager.m
+++ b/modules/gui/macosx/VLCInputManager.m
@@ -39,7 +39,9 @@
 #import "iTunes.h"
 #import "Spotify.h"
 
+#ifdef MAC_OS_X_VERSION_10_12_2
 #import <MediaPlayer/MediaPlayer.h>
+#endif
 
 #pragma mark Callbacks
 
diff --git a/modules/gui/macosx/VLCRemoteControlService.m b/modules/gui/macosx/VLCRemoteControlService.m
index 8c1237fe52..5e139b810a 100644
--- a/modules/gui/macosx/VLCRemoteControlService.m
+++ b/modules/gui/macosx/VLCRemoteControlService.m
@@ -25,7 +25,9 @@
 #import "VLCRemoteControlService.h"
 #import "VLCCoreInteraction.h"
 #import "VLCMain.h"
+#ifdef MAC_OS_X_VERSION_10_12_2
 #import <MediaPlayer/MediaPlayer.h>
+#endif
 #import "CompatibilityFixes.h"
 
 #define kVLCSettingPlaybackForwardSkipLength @(60)
@@ -68,8 +70,6 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
     commandCenter.bookmarkCommand.enabled = NO;
     commandCenter.enableLanguageOptionCommand.enabled = NO;
     commandCenter.disableLanguageOptionCommand.enabled = NO;
-    commandCenter.changeRepeatModeCommand.enabled = NO;
-    commandCenter.changeShuffleModeCommand.enabled = NO;
     commandCenter.seekForwardCommand.enabled = NO;
     commandCenter.seekBackwardCommand.enabled = NO;
 
@@ -136,8 +136,29 @@ static inline NSArray * RemoteCommandCenterCommandsToHandle()
         [coreInteraction jumpToTime:positionEvent.positionTime * CLOCK_FREQ];
         return MPRemoteCommandHandlerStatusSuccess;
     }
+    if (event.command == cc.changeRepeatModeCommand) {
+        MPChangeRepeatModeCommandEvent *repeatEvent = (MPChangeRepeatModeCommandEvent *)event;
+        MPRepeatType repeatType = repeatEvent.repeatType;
+        switch (repeatType) {
+            case MPRepeatTypeAll:
+                [coreInteraction repeatAll];
+                 break;
+
+            case MPRepeatTypeOne:
+                [coreInteraction repeatOne];
+                break;
+
+            default:
+                [coreInteraction repeatOff];
+                break;
+        }
+        return MPRemoteCommandHandlerStatusSuccess;
+    }
+    if (event.command == cc.changeShuffleModeCommand) {
+        [coreInteraction shuffle];
+        return MPRemoteCommandHandlerStatusSuccess;
+    }
 
-    NSAssert(NO, @"remote control event not handled");
     msg_Dbg(getIntf(), "%s Wasn't able to handle remote control event: %s",__PRETTY_FUNCTION__,[event.description UTF8String]);
     return MPRemoteCommandHandlerStatusCommandFailed;
 }



More information about the vlc-commits mailing list