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([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) {
[scrobbler start:pe];
if ([AudioScrobbler isRunning]) return;
}
// Note: We don't want to send a growl notification on resume.

View File

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

View File

@ -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"];
}
}