From 9d6f583eff180e936b51fe67edbda17d50b860e4 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Sun, 13 Oct 2013 15:13:27 -0700 Subject: [PATCH] Bypass sending notifications to Growl if Last.fm is enabled and running, as Last.fm has its own display notifications --- Application/PlaybackEventController.m | 1 + AudioScrobbler/AudioScrobbler.h | 2 ++ AudioScrobbler/AudioScrobbler.m | 28 +++++++++++++++------------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Application/PlaybackEventController.m b/Application/PlaybackEventController.m index 497cf3a82..c04161ae5 100644 --- a/Application/PlaybackEventController.m +++ b/Application/PlaybackEventController.m @@ -53,6 +53,7 @@ if (NO == [pe error]) { if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) { [scrobbler start:pe]; + if ([AudioScrobbler isRunning]) return; } // Note: We don't want to send a growl notification on resume. diff --git a/AudioScrobbler/AudioScrobbler.h b/AudioScrobbler/AudioScrobbler.h index 3bcc4b237..880859b40 100644 --- a/AudioScrobbler/AudioScrobbler.h +++ b/AudioScrobbler/AudioScrobbler.h @@ -34,6 +34,8 @@ semaphore_t _semaphore; } ++ (BOOL) isRunning; + - (void) start:(PlaylistEntry *)pe; - (void) stop; - (void) pause; diff --git a/AudioScrobbler/AudioScrobbler.m b/AudioScrobbler/AudioScrobbler.m index 76a69f6d0..49e3ffeda 100644 --- a/AudioScrobbler/AudioScrobbler.m +++ b/AudioScrobbler/AudioScrobbler.m @@ -67,6 +67,20 @@ escapeForLastFM(NSString *string) @implementation AudioScrobbler ++ (BOOL) isRunning +{ + NSArray *launchedApps = [[NSWorkspace sharedWorkspace] runningApplications]; + BOOL running = NO; + for(NSRunningApplication *app in launchedApps) { + if([[app bundleIdentifier] isEqualToString:@"fm.last.Last.fm"] || + [[app bundleIdentifier] isEqualToString:@"fm.last.Scrobbler"]) { + running = YES; + break; + } + } + return running; +} + - (id) init { if((self = [super init])) { @@ -74,18 +88,8 @@ escapeForLastFM(NSString *string) _pluginID = @"cog"; if([[NSUserDefaults standardUserDefaults] boolForKey:@"automaticallyLaunchLastFM"]) { - - NSArray *launchedApps = [[NSWorkspace sharedWorkspace] runningApplications]; - BOOL running = NO; - for(NSRunningApplication *app in launchedApps) { - if([[app bundleIdentifier] isEqualToString:@"fm.last.Last.fm"] || - [[app bundleIdentifier] isEqualToString:@"fm.last.Scrobbler"]) { - running = YES; - break; - } - } - - if(!running) { + + if(![AudioScrobbler isRunning]) { [[NSWorkspace sharedWorkspace] launchApplication:@"Last.fm.app"]; } }