Bypass sending notifications to Growl if Last.fm is enabled and running, as Last.fm has its own display notifications

CQTexperiment
Chris Moeller 2013-10-13 15:13:27 -07:00
parent 2655f22b7d
commit 9d6f583eff
3 changed files with 19 additions and 12 deletions

View File

@ -53,6 +53,7 @@
if (NO == [pe error]) { if (NO == [pe error]) {
if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) { if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) {
[scrobbler start:pe]; [scrobbler start:pe];
if ([AudioScrobbler isRunning]) return;
} }
// Note: We don't want to send a growl notification on resume. // Note: We don't want to send a growl notification on resume.

View File

@ -34,6 +34,8 @@
semaphore_t _semaphore; semaphore_t _semaphore;
} }
+ (BOOL) isRunning;
- (void) start:(PlaylistEntry *)pe; - (void) start:(PlaylistEntry *)pe;
- (void) stop; - (void) stop;
- (void) pause; - (void) pause;

View File

@ -67,14 +67,8 @@ escapeForLastFM(NSString *string)
@implementation AudioScrobbler @implementation AudioScrobbler
- (id) init + (BOOL) isRunning
{ {
if((self = [super init])) {
_pluginID = @"cog";
if([[NSUserDefaults standardUserDefaults] boolForKey:@"automaticallyLaunchLastFM"]) {
NSArray *launchedApps = [[NSWorkspace sharedWorkspace] runningApplications]; NSArray *launchedApps = [[NSWorkspace sharedWorkspace] runningApplications];
BOOL running = NO; BOOL running = NO;
for(NSRunningApplication *app in launchedApps) { for(NSRunningApplication *app in launchedApps) {
@ -84,8 +78,18 @@ escapeForLastFM(NSString *string)
break; break;
} }
} }
return running;
}
if(!running) { - (id) init
{
if((self = [super init])) {
_pluginID = @"cog";
if([[NSUserDefaults standardUserDefaults] boolForKey:@"automaticallyLaunchLastFM"]) {
if(![AudioScrobbler isRunning]) {
[[NSWorkspace sharedWorkspace] launchApplication:@"Last.fm.app"]; [[NSWorkspace sharedWorkspace] launchApplication:@"Last.fm.app"];
} }
} }