[vlc-commits] macosx: Move stop media playback to separate function

David Fuhrmann git at videolan.org
Sun Sep 3 14:27:48 CEST 2017


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun Sep  3 09:51:57 2017 +0200| [b4e93d6573281b01eb2bfdca0e2ac81b787d8fc9] | committer: David Fuhrmann

macosx: Move stop media playback to separate function

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

 modules/gui/macosx/VLCInputManager.m | 63 ++++++++++++++++++++----------------
 1 file changed, 35 insertions(+), 28 deletions(-)

diff --git a/modules/gui/macosx/VLCInputManager.m b/modules/gui/macosx/VLCInputManager.m
index 538af31dec..fba66e4e7e 100644
--- a/modules/gui/macosx/VLCInputManager.m
+++ b/modules/gui/macosx/VLCInputManager.m
@@ -271,34 +271,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
     }
 
     if (state == PLAYING_S) {
-        if (i_control_itunes > 0) {
-            // pause iTunes
-            if (!b_has_itunes_paused) {
-                iTunesApplication *iTunesApp = (iTunesApplication *) [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
-                if (iTunesApp && [iTunesApp isRunning]) {
-                    if ([iTunesApp playerState] == iTunesEPlSPlaying) {
-                        msg_Dbg(p_intf, "pausing iTunes");
-                        [iTunesApp pause];
-                        b_has_itunes_paused = YES;
-                    }
-                }
-            }
-
-            // pause Spotify
-            if (!b_has_spotify_paused) {
-                SpotifyApplication *spotifyApp = (SpotifyApplication *) [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
-
-                if (spotifyApp) {
-                    if ([spotifyApp respondsToSelector:@selector(isRunning)] && [spotifyApp respondsToSelector:@selector(playerState)]) {
-                        if ([spotifyApp isRunning] && [spotifyApp playerState] == kSpotifyPlayerStatePlaying) {
-                            msg_Dbg(p_intf, "pausing Spotify");
-                            [spotifyApp pause];
-                            b_has_spotify_paused = YES;
-                        }
-                    }
-                }
-            }
-        }
+        [self stopItunesPlayback];
 
         BOOL shouldDisableScreensaver = var_InheritBool(p_intf, "disable-screensaver");
 
@@ -381,6 +354,40 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
     [self sendDistributedNotificationWithUpdatedPlaybackStatus];
 }
 
+- (void)stopItunesPlayback
+{
+    intf_thread_t *p_intf = getIntf();
+    int controlItunes = var_InheritInteger(p_intf, "macosx-control-itunes");
+    if (controlItunes <= 0)
+        return;
+
+    // pause iTunes
+    if (!b_has_itunes_paused) {
+        iTunesApplication *iTunesApp = (iTunesApplication *) [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
+        if (iTunesApp && [iTunesApp isRunning]) {
+            if ([iTunesApp playerState] == iTunesEPlSPlaying) {
+                msg_Dbg(p_intf, "pausing iTunes");
+                [iTunesApp pause];
+                b_has_itunes_paused = YES;
+            }
+        }
+    }
+
+    // pause Spotify
+    if (!b_has_spotify_paused) {
+        SpotifyApplication *spotifyApp = (SpotifyApplication *) [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
+
+        if (spotifyApp) {
+            if ([spotifyApp respondsToSelector:@selector(isRunning)] && [spotifyApp respondsToSelector:@selector(playerState)]) {
+                if ([spotifyApp isRunning] && [spotifyApp playerState] == kSpotifyPlayerStatePlaying) {
+                    msg_Dbg(p_intf, "pausing Spotify");
+                    [spotifyApp pause];
+                    b_has_spotify_paused = YES;
+                }
+            }
+        }
+    }
+}
 
 - (void)resumeItunesPlayback:(id)sender
 {



More information about the vlc-commits mailing list