X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/efd57bc799aac892be3c161826168729b0419fb4..304ae643ec373b72dd98ad1cf52f09478e639a8b:/iTunesRemote.m?ds=inline diff --git a/iTunesRemote.m b/iTunesRemote.m index b14f74e..5ec512b 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -69,6 +69,19 @@ nil]; } +- (BOOL)showPrimaryInterface +{ + // Make this into AppleEvents... shouldn't be too hard, I'm just too tired to do it right now. + //tell application "iTunes" + // set frontmost to true + // set visible of browser window 1 to true + // set minimized of browser window 1 to false + // set view of browser window 1 to (playlist (index of current playlist)) + //end tell + //Someone do this plz kthx + return NO; +} + - (ITMTRemotePlayerRunningState)playerRunningState { NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; @@ -129,10 +142,12 @@ { int realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; - // ADD SUPPORT FOR RETURNING A ITMTRemotePlayerLibraryPlaylist WHEN PLAYLIST IS LIBRARY. switch (realResult) { + case 'cLiP': + return ITMTRemotePlayerLibraryPlaylist; + break; case 'cRTP': return ITMTRemotePlayerRadioPlaylist; break; @@ -143,9 +158,7 @@ - (int)currentPlaylistIndex { - int result; - result = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; - return result; + return [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; } - (NSString *)songTitleAtIndex:(int)index @@ -153,11 +166,14 @@ 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]; } +- (NSString *)currentSongUniqueIdentifier +{ + return @"BBQ"; +} + - (int)currentSongIndex { - int result; - result = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; - return result; + return [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; } - (NSString *)currentSongTitle @@ -197,26 +213,25 @@ - (float)currentSongRating { - int realResult = [[ITAppleEventCenter sharedCenter] - sendTwoTierAEWithRequestedKeyForNumber:@"pRte" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; - - return realResult / 100; + return [[ITAppleEventCenter sharedCenter] + sendTwoTierAEWithRequestedKeyForNumber:@"pRte" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN] / 100; } - (BOOL)setCurrentSongRating:(float)rating { - [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu), ----:obj { form:'prop', want:type('prop'), seld:type('pRte'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() } } }",(long)rating*100,[self currentSongIndex],[self currentPlaylistIndex]] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pRte'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }",(long)(rating*100),[self currentSongIndex]] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; return YES; } - (BOOL)equalizerEnabled { - return NO; + return [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:type('prop'), want:type('prop'), seld:type('pEQ '), from:() }" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + } - (BOOL)setEqualizerEnabled:(BOOL)enabled { - return NO; +[[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]; } - (NSArray *)eqPresets @@ -250,7 +265,7 @@ - (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]; + [[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; } @@ -359,7 +374,8 @@ - (BOOL)switchToEQAtIndex:(int)index { - [[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]; + // index should count from 0, but itunes counts from 1, so let's add 1. + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pEQP'), from:'null'() }, data:obj { form:'indx', want:type('cEQP'), seld:long(%lu), from:'null'() }",(index+1)] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; return YES; }