{
ITDebugLog(@"iTunesRemote begun");
savedPSN = [self iTunesPSN];
+ [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(notificationHandler:) name:@"com.apple.iTunes.playerInfo" object:@"com.apple.iTunes.player"];
return YES;
}
- (BOOL)halt
{
ITDebugLog(@"iTunesRemote halted");
+ [[NSDistributedNotificationCenter defaultCenter] removeObserver:self];
return YES;
}
NSString *temp1;
ITDebugLog(@"Getting current unique identifier.");
NSAppleEventDescriptor *descriptor = ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN);
- if ((descriptor == nil) || ([descriptor int32Value] == 'prop')) {
+ if ([descriptor int32Value] == 'prop') {
return @"0-0";
+ } else if (descriptor == nil) {
+ return nil;
}
SInt32 cls = [descriptor int32Value];
if ( ([self currentPlaylistClass] == ITMTRemotePlayerRadioPlaylist) || (cls == 'cURT') ) {
- (BOOL)goToPreviousSong
{
ITDebugLog(@"Go to previous track");
- ITSendAE('hook', 'Prev', &savedPSN);
+ ITSendAE('hook', 'Back', &savedPSN);
ITDebugLog(@"Go to previous track done");
return YES;
}
//Duplicate search results to playlist
for (i = 1; i <= [searchResults numberOfItems]; i++) {
+ //NSLog(@"%@", ITSendAEWithStringAndParameter(@"'----':obj { form:'prop', want:type('prop'), seld:prop('pnam'), from:aevt(@) }", *[[searchResults descriptorAtIndex:i] aeDesc], 'core', 'getd', &savedPSN));
ITSendAEWithStringAndObject(@"insh:obj { form:'name', want:type('cPly'), seld:\"MenuTunes\", from:'null'() }", [[searchResults descriptorAtIndex:i] aeDesc], 'core', 'clon', &savedPSN);
}
//Reset fixed indexing
return ([ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pcls'), from:obj { form:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }", 'core', 'getd', &savedPSN) int32Value] != 'prop');
}
+- (void)notificationHandler:(NSNotification *)note
+{
+ ITDebugLog(@"Received notification: %@", note);
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTTrackChanged" object:self userInfo:[note userInfo]];
+ ITDebugLog(@"Handled notification.");
+}
+
- (ProcessSerialNumber)iTunesPSN
{
/*NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications];