Commit fa601028 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: contacting an app using SBApplication can fail, be a bit more...

macosx: contacting an app using SBApplication can fail, be a bit more conservative to prevent runtime exceptions

(cherry picked from commit e9981efbf126136807a87215d0ce8aade192b846)
parent 1aca75ad
......@@ -1394,7 +1394,7 @@ static bool f_appExit = false;
iTunesApplication *iTunesApp = (iTunesApplication *) [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
if (iTunesApp && [iTunesApp isRunning]) {
if ([iTunesApp playerState] == iTunesEPlSPaused) {
msg_Dbg(p_intf, "Unpause iTunes...");
msg_Dbg(p_intf, "unpausing iTunes");
[iTunesApp playpause];
}
}
......@@ -1402,12 +1402,16 @@ static bool f_appExit = false;
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] == kSpotifyPlayerStatePaused) {
msg_Dbg(p_intf, "Unpause Spotify...");
msg_Dbg(p_intf, "unpausing Spotify");
[spotifyApp play];
}
}
}
}
}
b_has_itunes_paused = NO;
b_has_spotify_paused = NO;
......@@ -1437,7 +1441,7 @@ static bool f_appExit = false;
iTunesApplication *iTunesApp = (iTunesApplication *) [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];
if (iTunesApp && [iTunesApp isRunning]) {
if ([iTunesApp playerState] == iTunesEPlSPlaying) {
msg_Dbg(p_intf, "Pause iTunes...");
msg_Dbg(p_intf, "pausing iTunes");
[iTunesApp pause];
b_has_itunes_paused = YES;
}
......@@ -1447,13 +1451,18 @@ static bool f_appExit = false;
// 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, "Pause Spotify...");
msg_Dbg(p_intf, "pausing Spotify");
[spotifyApp pause];
b_has_spotify_paused = YES;
}
}
}
}
}
/* Declare user activity.
This wakes the display if it is off, and postpones display sleep according to the users system preferences
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment