+- (int)numberOfSongsInPlaylistAtIndex:(int)index
+{
+ int temp1;
+ ITDebugLog(@"Getting number of songs in playlist at index %i", index);
+ temp1 = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:[NSString stringWithFormat:@"kocl:type('cTrk'), '----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() }",index] eventClass:@"core" eventID:@"cnte" appPSN:savedPSN];
+ ITDebugLog(@"Getting number of songs in playlist at index %i done", index);
+ return temp1;
+}
+
+- (ITMTRemotePlayerSource)currentSource
+{
+ unsigned long fourcc;
+
+ ITDebugLog(@"Getting current source.");
+
+ fourcc = (unsigned long)[[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber :[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pKnd'), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }"] eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
+
+ switch (fourcc) {
+ case 'kTun':
+ ITDebugLog(@"Getting current source done. Source: Radio.");
+ return ITMTRemoteRadioSource;
+ break;
+ case 'kDev':
+ ITDebugLog(@"Getting current source done. Source: Generic Device.");
+ return ITMTRemoteGenericDeviceSource;
+ case 'kPod':
+ ITDebugLog(@"Getting current source done. Source: iPod.");
+ return ITMTRemoteiPodSource; //this is stupid
+ break;
+ case 'kMCD':
+ case 'kACD':
+ ITDebugLog(@"Getting current source done. Source: CD.");
+ return ITMTRemoteCDSource;
+ break;
+ case 'kUnk':
+ case 'kLib':
+ case 'kShd':
+ default:
+ ITDebugLog(@"Getting current source done. Source: Library.");
+ return ITMTRemoteLibrarySource;
+ break;
+ }
+}
+
+- (ITMTRemotePlayerPlaylistClass)currentPlaylistClass
+{
+ int realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
+
+ ITDebugLog(@"Getting current playlist class");
+ switch (realResult)
+ {
+ case 'cLiP':
+ ITDebugLog(@"Getting current playlist class done. Class: Library.");
+ return ITMTRemotePlayerLibraryPlaylist;
+ break;
+ case 'cRTP':
+ ITDebugLog(@"Getting current playlist class done. Class: Radio.");
+ return ITMTRemotePlayerRadioPlaylist;
+ break;
+ default:
+ ITDebugLog(@"Getting current playlist class done. Class: Standard playlist.");
+ return ITMTRemotePlayerPlaylist;
+ }
+}
+
+- (int)currentPlaylistIndex
+{
+ int temp1;
+ ITDebugLog(@"Getting current playlist index.");
+ temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
+ ITDebugLog(@"Getting current playlist index done.");
+ return temp1;
+}
+
+- (NSString *)songTitleAtIndex:(int)index
+{
+ NSString *temp1;
+ ITDebugLog(@"Getting song title at index %i.", index);
+ temp1 = [[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:savedPSN];
+ ITDebugLog(@"Getting song title at index %i done.", index);
+ return ( ([temp1 length]) ? temp1 : nil ) ;
+}
+
+- (int)currentAlbumTrackCount
+{
+ int temp1;
+ ITDebugLog(@"Getting current album track count.");
+ temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pTrC" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
+ if ( [self currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist ) { temp1 = 0; }
+ ITDebugLog(@"Getting current album track count done.");
+ return temp1;
+}
+
+- (int)currentSongTrack
+{
+ int temp1;
+ ITDebugLog(@"Getting current song track.");
+ temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pTrN" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
+ if ( [self currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist ) { temp1 = 0; }
+ ITDebugLog(@"Getting current song track done.");
+ return temp1;
+}
+
+- (NSString *)playerStateUniqueIdentifier
+{
+ NSString *temp1;
+ ITDebugLog(@"Getting current unique identifier.");
+ temp1 = [NSString stringWithFormat:@"%i-%i", [self currentPlaylistIndex], [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pDID" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]];
+ ITDebugLog(@"Getting current unique identifier done.");
+ return ( ([temp1 length]) ? temp1 : nil ) ;
+}
+
+- (int)currentSongIndex
+{
+ int temp1;
+ ITDebugLog(@"Getting current song index.");
+ temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
+ ITDebugLog(@"Getting current song index done.");
+ return temp1;
+}
+
+- (NSString *)currentSongTitle
+{
+ NSString *temp1;
+ ITDebugLog(@"Getting current song title.");
+ temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pnam" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
+ ITDebugLog(@"Getting current song title done.");
+ return ( ([temp1 length]) ? temp1 : nil ) ;
+}
+
+- (NSString *)currentSongArtist
+{
+ NSString *temp1;
+ ITDebugLog(@"Getting current song artist.");
+ if ( [self currentPlaylistClass] != ITMTRemotePlayerRadioPlaylist ) {
+ temp1 = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKey:@"pArt" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];