X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/ee13ab078aee1bb34f14817175119872da6864ea..701d53006945f9cf890e9b3d554f493d81f66640:/iTunesRemote.m diff --git a/iTunesRemote.m b/iTunesRemote.m index 4d19980..1ab3043 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -25,10 +25,6 @@ - (BOOL)begin { iTunesPSN = [self iTunesPSN]; - - [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationLaunched:) name:NSWorkspaceDidLaunchApplicationNotification object:nil]; - [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationTerminated:) name:NSWorkspaceDidTerminateApplicationNotification object:nil]; - return YES; } @@ -166,6 +162,16 @@ return [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }",index] eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; } +- (int)currentAlbumTrackCount +{ + return [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pTrC" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; +} + +- (int)currentSongTrack +{ + return [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pTrN" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; +} + - (NSString *)currentSongUniqueIdentifier { return [NSString stringWithFormat:@"%i-%i", [self currentPlaylistIndex], [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pDID" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]]; @@ -214,7 +220,7 @@ - (float)currentSongRating { return [[ITAppleEventCenter sharedCenter] - sendTwoTierAEWithRequestedKeyForNumber:@"pRte" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN] / 100; + sendTwoTierAEWithRequestedKeyForNumber:@"pRte" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN] / 100.0; } - (BOOL)setCurrentSongRating:(float)rating @@ -223,17 +229,18 @@ return YES; } -- (BOOL)equalizerEnabled +/* - (BOOL)equalizerEnabled { int thingy = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:type('prop'), want:type('prop'), seld:type('pEQ '), from:() }" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; NSLog(@"Debug equalizerEnabled: %i", thingy); - return thingy; + return thingy; } - (BOOL)setEqualizerEnabled:(BOOL)enabled { -[[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pEQ '), from:'null'() }",enabled] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; -} + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pEQ '), from:'null'() }",enabled] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; + return YES; +} */ - (NSArray *)eqPresets { @@ -280,12 +287,13 @@ - (BOOL)setShuffleEnabled:(BOOL)enabled { [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu) ----:obj { form:'prop', want:type('prop'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }",enabled] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; + return YES; } - (ITMTRemotePlayerRepeatMode)repeatMode { - FourCharCode m00f; - int result; + FourCharCode m00f = 0; + int result = 0; m00f = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pRpt" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; @@ -307,7 +315,7 @@ - (BOOL)setRepeatMode:(ITMTRemotePlayerRepeatMode)repeatMode { - FourCharCode m00f; + FourCharCode m00f = 0; switch (repeatMode) { case ITMTRemotePlayerRepeatOff: @@ -322,7 +330,7 @@ } [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu) ----:obj { form:'prop', want:type('pRpt'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }",m00f] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; - + return YES; } - (BOOL)play @@ -404,26 +412,4 @@ return number; } -- (void)applicationLaunched:(NSNotification *)note -{ - NSDictionary *info = [note userInfo]; - - if ([[info objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) { - iTunesPSN.highLongOfPSN = [[info objectForKey:@"NSApplicationProcessSerialNumberHigh"] longValue]; - iTunesPSN.lowLongOfPSN = [[info objectForKey:@"NSApplicationProcessSerialNumberLow"] longValue]; - - [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTRemoteAppDidLaunchNotification" object:nil]; - } -} - -- (void)applicationTerminated:(NSNotification *)note -{ - NSDictionary *info = [note userInfo]; - - if ([[info objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) { - iTunesPSN.highLongOfPSN = kNoProcess; - [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTRemoteAppDidTerminateNotification" object:nil]; - } -} - @end