X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/74d6135e4db4cf9a70994d5bc2062be30311d0f3..58ff9958be5f49991431f24f220bccc2ac5114d6:/iTunesRemote.m diff --git a/iTunesRemote.m b/iTunesRemote.m index e479c63..bf2d9d3 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -43,7 +43,7 @@ return YES; } -- (BOOL)isAppRunning +- (ITMTRemotePlayerRunningStatus)playerRunningStatus { NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; int i; @@ -52,10 +52,10 @@ for (i = 0; i < count; i++) { if ([[[apps objectAtIndex:i] objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) { - return YES; + return ITMTRemotePlayerRunning; } } - return NO; + return ITMTRemotePlayerNotRunning; } - (ITMTRemotePlayerState)playerState @@ -66,15 +66,15 @@ { default: case 'kPSS': - return stopped; + return ITMTRemotePlayerStopped; case 'kPSP': - return playing; + return ITMTRemotePlayerPlaying; case 'kPSp': - return paused; + return ITMTRemotePlayerPaused; case 'kPSR': - return rewinding; + return ITMTRemotePlayerRewinding; case 'kPSF': - return forwarding; + return ITMTRemotePlayerForwarding; } return stopped; @@ -168,21 +168,27 @@ - (float)currentSongRating { - return 0.00; + int realResult = [[ITAppleEventCenter sharedCenter] + sendTwoTierAEWithRequestedKeyForNumber:@"pRte" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + + return realResult / 100; } - (BOOL)setCurrentSongRating:(float)rating { - return NO; + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu), ----:obj { form:'prop', want:type('prop'), seld:type('pRte'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } ",(long)rating*100] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; + return YES; } - (float)volume { - return 1.00; + long vol = [[ITAppleEventCenter sharedCenter] sendAEWithRequestedKeyForNumber:@"pVol" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + return vol / 100; } - (BOOL)setVolume:(float)volume { + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu), ----:obj { form:'prop', want:type('prop'), seld:type('pVol'), from:'null'() }",(long)volume*100] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; return NO; } @@ -258,8 +264,7 @@ - (BOOL)switchToEQAtIndex:(int)index { - [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:obj { form:'indx', want:type('cEQP'), seld:long(%lu), from:'null'() }, '----':obj { form:'prop', want:type('prop'), seld:type('pEQP'), from:'null'() }",index] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; - [[ITAppleEventCenter sharedCenter] sendAEWithSendString:@"data:1, '----':obj { form:'prop', want:type('prop'), seld:type('pEQ '), from:'null'() }" eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:obj { form:'ID ', want:type('cEQP'), seld:long(%lu), from:'null'() }, ----:obj { form:'prop', want:type('prop'), seld:type('pEQP'), from:'null'() }",index] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; return YES; }