return YES;
}
-- (int)numberOfPlaylists
+- (NSArray *)playlists
{
- NSString *result = [self runScriptAndReturnResult:@"get number of playlists"];
- return [result intValue];
+ int i;
+ int numPresets = [[self runScriptAndReturnResult:@"get number of playlists"] intValue];
+ NSMutableArray *presets = [[NSMutableArray alloc] init];
+
+ for (i = 0; i < numPresets; i++) {
+ [presets addObject:[self runScriptAndReturnResult:[NSString stringWithFormat:@"get name of playlist %i", i]]];
+ }
+
+ return [NSArray arrayWithArray:presets];
}
- (int)numberOfSongsInPlaylistAtIndex:(int)index
- (NSString *)songTitleAtIndex:(int)index
{
- NSString *result = [self runScriptAndReturnResult:[NSString stringWithFormat:@"return name of track %i", index]];
+ NSString *result = [self runScriptAndReturnResult:[NSString stringWithFormat:@"get name of track %i of current playlist", index]];
return result;
}
- (NSString *)currentSongLength
{
- return [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pDur"
+ return [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pTim"
fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd"
appPSN:[self iTunesPSN]];
}
return [NSArray arrayWithArray:presets];
}
+- (int)currentEQPresetIndex
+{
+ int result;
+ result = [[ITAppleEventCenter sharedCenter]
+ sendTwoTierAEWithRequestedKeyForNumber:@"pidx"
+ fromObjectByKey:@"pEQP" eventClass:@"core" eventID:@"getd"
+ appPSN:[self iTunesPSN]];
+ return result;
+}
+
- (BOOL)play
{
[[ITAppleEventCenter sharedCenter] sendAEWithEventClass:@"hook" eventID:@"Play"
- (BOOL)goToNextSong
{
- NSLog(@"%@", [self classOfPlaylistAtIndex:3]);
- //[[ITAppleEventCenter sharedCenter] sendAEWithEventClass:@"hook" eventID:@"Next"
- // appPSN:[self iTunesPSN]];
+ [[ITAppleEventCenter sharedCenter] sendAEWithEventClass:@"hook" eventID:@"Next"
+ appPSN:[self iTunesPSN]];
return YES;
}
- (BOOL)switchToPlaylistAtIndex:(int)index
{
[self runScriptAndReturnResult:[NSString stringWithFormat:
- @"set current playlist to playlist %i", index]];
+ @"play playlist %i", index]];
return NO;
}
{
[self runScriptAndReturnResult:[NSString stringWithFormat:
@"set current EQ preset to EQ preset %i", index]];
+ [self runScriptAndReturnResult:@"set EQ enabled to 1"];
return NO;
}