[vlc-commits] macosx: add support for Apple Music

Felix Paul Kühne git at videolan.org
Thu Nov 14 11:56:13 CET 2019


vlc/vlc-3.0 | branch: master | Felix Paul Kühne <felix at feepk.net> | Thu Nov 14 11:55:44 2019 +0100| [2164633b495bff4f6435b434ee05dc7572e4a663] | committer: Felix Paul Kühne

macosx: add support for Apple Music

This matches the previous iTunes support.

This is a manual backport of 20bf0e212.

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

 NEWS                                 |  3 ++-
 modules/gui/macosx/SPMediaKeyTap.m   |  1 +
 modules/gui/macosx/VLCInputManager.m | 26 +++++++++++++++++++++++++-
 3 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 66755c1961..c2f5a215e5 100644
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,7 @@ Core:
 Demux:
  * Fix TTML entities not passed to decoder
  * Misc raw H264/HEVC frame rate fixes
- * Fixed adaptive regression on TS format change (mostly HLS)
+ * Fix adaptive regression on TS format change (mostly HLS)
 
 Packetizers:
  * Fixes H264/HEVC incomplete draining in some cases
@@ -19,6 +19,7 @@ Decoder:
 
 macOS:
  * Fix Apple Remote support on macOS Catalina
+ * Add support for pausing Apple Music on macOS Catalina
 
 Misc:
  * Add missing .wpl & .zpl file associations on Windows
diff --git a/modules/gui/macosx/SPMediaKeyTap.m b/modules/gui/macosx/SPMediaKeyTap.m
index 3083660bde..5b9505995a 100644
--- a/modules/gui/macosx/SPMediaKeyTap.m
+++ b/modules/gui/macosx/SPMediaKeyTap.m
@@ -177,6 +177,7 @@ static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEv
             [[NSBundle mainBundle] bundleIdentifier], // your app
             @"com.spotify.client",
             @"com.apple.iTunes",
+            @"com.apple.Music",
             @"com.apple.QuickTimePlayerX",
             @"com.apple.quicktimeplayer",
             @"com.apple.iWork.Keynote",
diff --git a/modules/gui/macosx/VLCInputManager.m b/modules/gui/macosx/VLCInputManager.m
index f4ada0f9a3..2b736dc2da 100644
--- a/modules/gui/macosx/VLCInputManager.m
+++ b/modules/gui/macosx/VLCInputManager.m
@@ -158,8 +158,9 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 
     IOPMAssertionID userActivityAssertionID;
 
-    /* iTunes/Spotify play/pause support */
+    /* iTunes/Apple Music/Spotify play/pause support */
     BOOL b_has_itunes_paused;
+    BOOL b_has_applemusic_paused;
     BOOL b_has_spotify_paused;
 
     NSTimer *hasEndedTimer;
@@ -368,6 +369,18 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
         }
     }
 
+    // pause Apple Music
+    if (!b_has_applemusic_paused) {
+        iTunesApplication *iTunesApp = (iTunesApplication *) [SBApplication applicationWithBundleIdentifier:@"com.apple.Music"];
+        if (iTunesApp && [iTunesApp isRunning]) {
+            if ([iTunesApp playerState] == iTunesEPlSPlaying) {
+                msg_Dbg(p_intf, "pausing Apple Music");
+                [iTunesApp pause];
+                b_has_itunes_paused = YES;
+            }
+        }
+    }
+
     // pause Spotify
     if (!b_has_spotify_paused) {
         SpotifyApplication *spotifyApp = (SpotifyApplication *) [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
@@ -398,6 +411,16 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
             }
         }
 
+        if (b_has_applemusic_paused) {
+            iTunesApplication *iTunesApp = (iTunesApplication *) [SBApplication applicationWithBundleIdentifier:@"com.apple.Music"];
+            if (iTunesApp && [iTunesApp isRunning]) {
+                if ([iTunesApp playerState] == iTunesEPlSPaused) {
+                    msg_Dbg(p_intf, "unpausing Apple Music");
+                    [iTunesApp playpause];
+                }
+            }
+        }
+
         if (b_has_spotify_paused) {
             SpotifyApplication *spotifyApp = (SpotifyApplication *) [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
             if (spotifyApp) {
@@ -412,6 +435,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
     }
 
     b_has_itunes_paused = NO;
+    b_has_applemusic_paused = NO;
     b_has_spotify_paused = NO;
 }
 



More information about the vlc-commits mailing list