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,9 +1402,13 @@ static bool f_appExit = false;
if (b_has_spotify_paused) {
SpotifyApplication *spotifyApp = (SpotifyApplication *) [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
if ([spotifyApp isRunning] && [spotifyApp playerState] == kSpotifyPlayerStatePaused) {
msg_Dbg(p_intf, "Unpause Spotify...");
[spotifyApp play];
if (spotifyApp) {
if ([spotifyApp respondsToSelector:@selector(isRunning)] && [spotifyApp respondsToSelector:@selector(playerState)]) {
if ([spotifyApp isRunning] && [spotifyApp playerState] == kSpotifyPlayerStatePaused) {
msg_Dbg(p_intf, "unpausing Spotify");
[spotifyApp play];
}
}
}
}
}
......@@ -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,10 +1451,15 @@ static bool f_appExit = false;
// pause Spotify
if (!b_has_spotify_paused) {
SpotifyApplication *spotifyApp = (SpotifyApplication *) [SBApplication applicationWithBundleIdentifier:@"com.spotify.client"];
if ([spotifyApp isRunning] && [spotifyApp playerState] == kSpotifyPlayerStatePlaying) {
msg_Dbg(p_intf, "Pause Spotify...");
[spotifyApp pause];
b_has_spotify_paused = YES;
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;
}
}
}
}
}
......
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