From c7829bc6dbbfe0dde4712a164f49ce253300517a Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Thu, 13 Mar 2003 18:26:37 +0000 Subject: [PATCH 01/16] Wtf? What the hell? Where did that "op" come from? --- iTunesRemote.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iTunesRemote.m b/iTunesRemote.m index 8956f47..7bb71c5 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -1,4 +1,4 @@ -op#import "iTunesRemote.h" +#import "iTunesRemote.h" @implementation iTunesRemote -- 2.20.1 From 6f4e496029228bcdf5bedb233e45ca2b8e1f99ff Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Fri, 14 Mar 2003 01:26:52 +0000 Subject: [PATCH 02/16] Added a menu update. Hopefully it might make things play a bit better during menu updates when the menu is down. --- MenuTunes.m | 1 + 1 file changed, 1 insertion(+) diff --git a/MenuTunes.m b/MenuTunes.m index 5f94ae7..ee35882 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -449,6 +449,7 @@ didHaveAlbumName = (([curAlbumName length] > 0) ? YES : NO); } } + [menu update]; } //Rebuild the upcoming songs submenu. Can be improved a lot. -- 2.20.1 From e40a6bb44d76a738d58a321039b6932c4688b12a Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Fri, 14 Mar 2003 02:19:01 +0000 Subject: [PATCH 03/16] Fixed some stuff with the equalizer menu. Fix the plugin EQ stuff please! :) --- MenuTunes.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MenuTunes.m b/MenuTunes.m index ee35882..d2fdaf2 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -793,8 +793,8 @@ int curSet = [currentRemote currentEQPresetIndex]; int item = [[sender representedObject] intValue]; [currentRemote switchToEQAtIndex:item]; - [[eqMenu itemAtIndex:curSet - 1] setState:NSOffState]; - [[eqMenu itemAtIndex:item - 1] setState:NSOnState]; + [[eqMenu itemAtIndex:curSet + 1] setState:NSOffState]; + [[eqMenu itemAtIndex:item + 2] setState:NSOnState]; } - (void)playPause:(id)sender -- 2.20.1 From 4b79b3476d8846420e66690e29e265aacaf172cf Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Fri, 14 Mar 2003 04:30:32 +0000 Subject: [PATCH 04/16] Updated ITMTRemote API, and bare documentation (and some filled in). I have yet to make iTunesRemote comply fully to this new API, but that's coming up soon. --- ITMTRemote.h | 255 ++++++++++++++++++++++++++++++++++++++++----------- ITMTRemote.m | 57 ++++++++---- 2 files changed, 243 insertions(+), 69 deletions(-) diff --git a/ITMTRemote.h b/ITMTRemote.h index 0caca6d..57a3228 100755 --- a/ITMTRemote.h +++ b/ITMTRemote.h @@ -15,139 +15,290 @@ * */ -/* - * TO DO: - * - * - Capability methods - * - */ - -/*! @header ITMTRemote - * @abstract Declares the necessary protocol and class to implement a MenuTunes Remote. +/*! + * @header ITMTRemote + * @discussion This header defines the Objective-C protocol which all MenuTunes Remote plugins must implement. To build a remote, create a subclass of the ITMTRemote object, and implement each method in the ITMTRemote protocol. */ - #import +/*! + @enum ITMTRemotePlayerRunningState + @abstract Possible running states for the remote's player. + @discussion Used in fuctions that report or take the running state of the remote's player application. + @constant ITMTRemotePlayerNotRunning The remote's player isn't running. + @constant ITMTRemotePlayerLaunching The remote's player is starting up, or is running, but not yet accepting remote commands. + @constant ITMTRemotePlayerRunning The remote's player is running, and as such, is accepting remote commands. + */ typedef enum { ITMTRemotePlayerNotRunning = -1, ITMTRemotePlayerLaunching, ITMTRemotePlayerRunning -} ITMTRemotePlayerRunningStatus; +} ITMTRemotePlayerRunningState; +/*! + @enum ITMTRemotePlayerPlayingState + @abstract Possible playing states for the remote's player. + @discussion Used in functions that report or take the playing state of the remote's player application. + @constant ITMTRemotePlayerStopped The remote's player is stopped. + @constant ITMTRemotePlayerPaused The remote's player is paused. + @constant ITMTRemotePlayerPlaying The remote's player is playing. + @constant ITMTRemotePlayerRewinding The remote's player is rewinding. + @constant ITMTRemotePlayerForwarding The remote's player is forwarding. + */ typedef enum { ITMTRemotePlayerStopped = -1, ITMTRemotePlayerPaused, ITMTRemotePlayerPlaying, ITMTRemotePlayerRewinding, ITMTRemotePlayerForwarding -} ITMTRemotePlayerState; +} ITMTRemotePlayerPlayingState; -/*! @protocol ITMTRemote - * @abstract Declares what a MenuTunes Remote must be able to do. - * @discussion A MenuTunes Remote must be able to return and change state information. +/*! + * @protocol ITMTRemote + * @discussion The Objective-C protocol which all MenuTunes remotes must implement. */ @protocol ITMTRemote - -/*! @method remote - * @abstract Returns an autoreleased instance of the remote. - * @discussion Should be very quick and compact. - * EXAMPLE: - * + (id)remote - * { - * return [[[MyRemote alloc] init] autorelease]; - * } - * @result The instance. +/*! + * @method remote + * @abstract Returns an autoreleased instance of the remote. + * @discussion Should be very quick and compact. + * + * EXAMPLE:
+ * + (id)remote
+ * {
+ *      return [[[MyRemote alloc] init] autorelease];
+ * } + * + * @result An instance of the remote. */ + (id)remote; -/*! @method pluginTitle: - * @abstract Returns the title of the plugin, which should be player name. - * @result An NSString containing the title. +/*! + * @method remoteTitle + * @abstract Returns the remote's title/name. + * @discussion This title is shown while the user is selecting which remote to use. This is for informational purposes only. + * @result An NSString containing the title/name of the remote. */ -- (NSString *)pluginTitle; +- (NSString *)remoteTitle; -/*! @method pluginInformation: - * @abstract Returns a description of the remote. - * @result An NSString containing the description. +/*! + * @method remoteInformation + * @abstract Returns the remote's information. + * @discussion Information on the remote that the user will see when selecting which remote to use. The information returned here has no bearing on how the remote works, it's simply here for informing the user. + * @result An NSString containing the information for the remote. */ -- (NSString *)pluginInformation; +- (NSString *)remoteInformation; -/*! @method pluginIcon: - * @abstract Returns a icon for the remote. - * @result An NSImage containing the icon. +/*! + * @method remoteIcon + * @abstract Returns the remote's icon. + * @discussion This icon is shown while the user is selecting which remote to use. Typically, this is the remote's player's application icon, however it can be anything you like. + * @result An NSImage containing the icon of the remote. */ -- (NSImage *)pluginIcon; +- (NSImage *)remoteIcon; -/*! @method begin: - * @abstract Sent when the plugin should begin operation. - * @result A result code signifying success. +/*! + * @method begin + * @abstract Sent when the remote should begin operation. + * @result A result code signifying success. */ - (BOOL)begin; -/*! @method halt: - * @abstract Sent when the plugin should cease operation. - * @result A result code signifying success. +/*! + * @method halt + * @abstract Sent when the remote should cease operation. + * @result A result code signifying success. */ - (BOOL)halt; +/*! + * @method playerFullName + * @abstract Returns the remote's player's application filename. + * @discussion This string should be the name typically used by the remote's player's application bundle/file. For example, Panic's Audion audio player is known simply as "Audion", however, the application bundle is called "Audion 3" for version 3 of their application. This should return "Audion 3", not simply "Audion". See playerSimpleName. + * @result An NSString containing the remote's player's application filename + */ - (NSString *)playerFullName; +/*! + * @method playerSimpleName + * @abstract Returns the simplified name of the remote's player. + * @discussion This is the name used in the User Interface for when referring to the remote's player. Continuing the example from the playerFullName method, this method would return simply "Audion", as that is how the player is known. + * @result An NSString containing the simplified name of the remote's player. + */ - (NSString *)playerSimpleName; -/*! @method playerRunningStatus: - * @abstract Returns controlled application's running status (is or isn't running). - * @result BOOL of the controlled application's running status. +/*! + * @method capabilities + * @abstract Returns a dictionary defining the capabilities of the remote and it's player. + * @discussion Discussion Forthcoming. + * @result An NSDictionary defining the capabilities of the remote and it's player. */ -- (ITMTRemotePlayerRunningStatus)playerRunningStatus; +- (NSDictionary *)capabilities; -/*! @method playerState: - * @abstract Returns controlled application's playing state. - * @result ITMTRemotePlayerState of the controlled application's playing state. +/*! + * @method playerRunningState + * @abstract Returns the running state of the remote's player. + * @discussion While most remotes will use only ITMTRemotePlayerNotRunning or ITMTRemotePlayerRunning, we have included support for ITMTRemotePlayerLaunching (see ITMTRemotePlayerRunningState) for remotes that want the most precise control over their player's process managment. + * @result An ITMTRemotePlayerRunningState defining the running state of the remote's player. */ -- (ITMTRemotePlayerState)playerState; +- (ITMTRemotePlayerRunningState)playerRunningState; +/*! + * @method playerPlayingState + */ +- (ITMTRemotePlayerPlayingState)playerPlayingState; + +/*! + * @method playlists + */ - (NSArray *)playlists; + +/*! + * @method numberOfSongsInPlaylistAtIndex: + */ - (int)numberOfSongsInPlaylistAtIndex:(int)index; + +/*! + * @method classOfPlaylistAtIndex: + */ - (NSString *)classOfPlaylistAtIndex:(int)index; + +/*! + * @method currentPlaylistIndex + */ - (int)currentPlaylistIndex; +/*! + * @method songTitleAtIndex: + */ - (NSString *)songTitleAtIndex:(int)index; + +/*! + * @method currentSongIndex + */ - (int)currentSongIndex; +/*! + * @method currentSongTitle + */ - (NSString *)currentSongTitle; + +/*! + * @method currentSongArtist + */ - (NSString *)currentSongArtist; + +/*! + * @method currentSongAlbum + */ - (NSString *)currentSongAlbum; + +/*! + * @method currentSongGenre + */ - (NSString *)currentSongGenre; + +/*! + * @method currentSongLength + */ - (NSString *)currentSongLength; + +/*! + * @method currentSongRemaining + */ - (NSString *)currentSongRemaining; +/*! + * @method currentSongRating + */ - (float)currentSongRating; + +/*! + * @method setCurrentSongRating: + */ - (BOOL)setCurrentSongRating:(float)rating; +/*! + * @method equalizerEnabled + */ - (BOOL)equalizerEnabled; + +/*! + * @method setEqualizerEnabled: + */ - (BOOL)setEqualizerEnabled:(BOOL)enabled; +/*! + * @method eqPresets + */ - (NSArray *)eqPresets; + +/*! + * @method currentEQPresetIndex + */ - (int)currentEQPresetIndex; +/*! + * @method volume + */ - (float)volume; + +/*! + * @method setVolume: + */ - (BOOL)setVolume:(float)volume; +/*! + * @method play + */ - (BOOL)play; + +/*! + * @method pause + */ - (BOOL)pause; + +/*! + * @method goToNextSong + */ - (BOOL)goToNextSong; + +/*! + * @method goToPreviousSong + */ - (BOOL)goToPreviousSong; + +/*! + * @method forward + */ - (BOOL)forward; + +/*! + * @method rewind + */ - (BOOL)rewind; +/*! + * @method switchToPlaylistAtIndex: + */ - (BOOL)switchToPlaylistAtIndex:(int)index; + +/*! + * @method switchToSongAtIndex: + */ - (BOOL)switchToSongAtIndex:(int)index; + +/*! + * @method switchToEQAtIndex: + */ - (BOOL)switchToEQAtIndex:(int)index; @end - +/*! + * @class ITMTRemote + */ @interface ITMTRemote : NSObject @end diff --git a/ITMTRemote.m b/ITMTRemote.m index c003989..d1cac3e 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -1,6 +1,5 @@ #import "ITMTRemote.h" - @implementation ITMTRemote + (id)remote @@ -8,17 +7,17 @@ return nil; } -- (NSString *)title +- (NSString *)remoteTitle { return nil; } -- (NSString *)information; +- (NSString *)remoteInformation { return nil; } -- (NSImage *)icon +- (NSImage *)remoteIcon { return nil; } @@ -33,14 +32,29 @@ return NO; } -- (ITMTRemotePlayerRunningStatus)playerRunningStatus +- (NSString *)playerFullName +{ + return nil; +} + +- (NSString *)playerSimpleName +{ + return nil; +} + +- (NSDictionary *)capabilities +{ + return nil; +} + +- (ITMTRemotePlayerRunningStatus)playerRunningState { - return ITMTRemotePlayerNotRunning; + return nil; } -- (ITMTRemotePlayerState)playerState +- (ITMTRemotePlayerPlayingState)playerPlayingState { - return ITMTRemotePlayerStopped; + return nil; } - (NSArray *)playlists @@ -50,7 +64,7 @@ - (int)numberOfSongsInPlaylistAtIndex:(int)index { - return 0; + return nil; } - (NSString *)classOfPlaylistAtIndex:(int)index @@ -105,7 +119,7 @@ - (float)currentSongRating { - return 0.00; + return nil; } - (BOOL)setCurrentSongRating:(float)rating @@ -113,24 +127,34 @@ return NO; } -- (float)volume +- (BOOL)equalizerEnabled { - return 1.00; + return NO; } -- (BOOL)setVolume:(float)volume +- (BOOL)setEqualizerEnabled:(BOOL)enabled { return NO; } -- (NSArray *)eqPresets; +- (NSArray *)eqPresets { return nil; } - (int)currentEQPresetIndex { - return 0; + return nil; +} + +- (float)volume +{ + return nil; +} + +- (BOOL)setVolume:(float)volume +{ + return NO; } - (BOOL)play @@ -153,7 +177,7 @@ return NO; } -- (BOOL)fastForward +- (BOOL)forward { return NO; } @@ -178,5 +202,4 @@ return NO; } - @end -- 2.20.1 From 03c0449f8664bc77b4aaa4681732382b8fcee91c Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Fri, 14 Mar 2003 04:52:28 +0000 Subject: [PATCH 05/16] iTunesRemote updated to fit new ITMTRemote API changes. --- iTunesRemote.h | 2 + iTunesRemote.m | 117 +++++++++++++++++++++++++++---------------------- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/iTunesRemote.h b/iTunesRemote.h index 04b1cdb..384c24c 100755 --- a/iTunesRemote.h +++ b/iTunesRemote.h @@ -17,4 +17,6 @@ ProcessSerialNumber iTunesPSN; } - (ProcessSerialNumber)iTunesPSN; +- (void)applicationLaunched:(NSNotification *)note; +- (void)applicationTerminated:(NSNotification *)note; @end diff --git a/iTunesRemote.m b/iTunesRemote.m index 7bb71c5..639843d 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -7,17 +7,17 @@ return [[[iTunesRemote alloc] init] autorelease]; } -- (NSString *)title +- (NSString *)remoteTitle { - return @"iTunes"; + return @"iTunes Remote"; } -- (NSString *)information; +- (NSString *)remoteInformation { - return @"Default MenuTunes plugin to control iTunes. Written by iThink Software."; + return @"Default MenuTunes plugin to control iTunes, by iThink Software."; } -- (NSImage *)icon +- (NSImage *)remoteIcon { return nil; } @@ -25,11 +25,10 @@ - (BOOL)begin { iTunesPSN = [self iTunesPSN]; - - //Register for application termination in NSWorkspace + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationLaunched:) name:NSWorkspaceDidLaunchApplicationNotification object:nil]; [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationTerminated:) name:NSWorkspaceDidTerminateApplicationNotification object:nil]; - + return YES; } @@ -43,22 +42,36 @@ return YES; } -- (ITMTRemotePlayerRunningStatus)playerRunningStatus +- (NSString *)playerFullName +{ + return @"iTunes"; +} + +- (NSString *)playerSimpleName +{ + return @"iTunes"; +} + +- (NSDictionary *)capabilities +{ + return nil; +} + +- (ITMTRemotePlayerRunningStatus)playerRunningState { NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; int i; int count = [apps count]; - + for (i = 0; i < count; i++) { - if ([[[apps objectAtIndex:i] objectForKey:@"NSApplicationName"] - isEqualToString:@"iTunes"]) { + if ([[[apps objectAtIndex:i] objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) { return ITMTRemotePlayerRunning; } } return ITMTRemotePlayerNotRunning; } -- (ITMTRemotePlayerState)playerState +- (ITMTRemotePlayerPlayingState)playerPlayingState { long result = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:'prop', want:type('prop'), seld:type('pPlS'), from:'null'() }" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; @@ -85,16 +98,14 @@ long i = 0; const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cPly'), '----':(), &subj:()" eventClass:@"core" eventID:@"cnte" appPSN:iTunesPSN]; NSMutableArray *playlists = [[NSMutableArray alloc] initWithCapacity:numPlaylists]; - - - for (i = 1; i <= numPlaylists; i++) { - const long j = i; - NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() } }",(unsigned long)j]; - NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; - //NSLog(@"sent event cur %d max %d",i,numPlaylists); - [playlists addObject:theObj]; - } - return [playlists autorelease]; + + for (i = 1; i <= numPlaylists; i++) { + const long j = i; + NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() } }",(unsigned long)j]; + NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + [playlists addObject:theObj]; + } + return [playlists autorelease]; } - (int)numberOfSongsInPlaylistAtIndex:(int)index @@ -104,18 +115,19 @@ - (NSString *)classOfPlaylistAtIndex:(int)index { - int realResult = [[ITAppleEventCenter sharedCenter] - sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; - - if (realResult == 'cRTP') return @"radio tuner playlist"; - else return @"playlist"; + int realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + + if (realResult == 'cRTP') { + return @"radio tuner playlist"; + } else { + return @"playlist"; + } } - (int)currentPlaylistIndex { int result; - result = [[ITAppleEventCenter sharedCenter] - sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + result = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; return result; } @@ -190,39 +202,41 @@ return NO; } -- (float)volume -{ - 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; -} - -- (NSArray *)eqPresets; +- (NSArray *)eqPresets { int i; long numPresets = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cEQP'), '----':(), &subj:()" eventClass:@"core" eventID:@"cnte" appPSN:iTunesPSN]; NSMutableArray *presets = [[NSMutableArray alloc] initWithCapacity:numPresets]; - - for (i = 1; i <= numPresets; i++) { - NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cEQP'), seld:long(%lu), from:'null'() } }",i] eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; - if (theObj) [presets addObject:theObj]; - } - return [presets autorelease]; + + for (i = 1; i <= numPresets; i++) { + NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cEQP'), seld:long(%lu), from:'null'() } }",i] eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + if (theObj) { + [presets addObject:theObj]; + } + } + return [presets autorelease]; } - (int)currentEQPresetIndex { int result; result = [[ITAppleEventCenter sharedCenter] - sendTwoTierAEWithRequestedKeyForNumber:@"pidx"fromObjectByKey:@"pEQP" eventClass:@"core" eventID:@"getd"appPSN:iTunesPSN]; + sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pEQP" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; return result; } +- (float)volume +{ + 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; +} + - (BOOL)play { [[ITAppleEventCenter sharedCenter] sendAEWithEventClass:@"hook" eventID:@"Play" appPSN:iTunesPSN]; @@ -247,7 +261,7 @@ return YES; } -- (BOOL)fastForward +- (BOOL)forward { [[ITAppleEventCenter sharedCenter] sendAEWithEventClass:@"hook" eventID:@"Fast" appPSN:iTunesPSN]; return YES; @@ -259,7 +273,6 @@ return YES; } - - (BOOL)switchToPlaylistAtIndex:(int)index { [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:() }",index] eventClass:@"hook" eventID:@"Play" appPSN:iTunesPSN]; -- 2.20.1 From 0a1be7120daf3895af462672f59a2889a6c9c581 Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Fri, 14 Mar 2003 04:54:24 +0000 Subject: [PATCH 06/16] Whoops. Quick fix... I forgot a change in the class files. --- ITMTRemote.m | 2 +- iTunesRemote.m | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ITMTRemote.m b/ITMTRemote.m index d1cac3e..72bd8df 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -47,7 +47,7 @@ return nil; } -- (ITMTRemotePlayerRunningStatus)playerRunningState +- (ITMTRemotePlayerRunningState)playerRunningState { return nil; } diff --git a/iTunesRemote.m b/iTunesRemote.m index 639843d..a5a1f82 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -57,7 +57,7 @@ return nil; } -- (ITMTRemotePlayerRunningStatus)playerRunningState +- (ITMTRemotePlayerRunningState)playerRunningState { NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; int i; -- 2.20.1 From 4b426dd2e4cb2a9efccdba130dfaf86f735f58b5 Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Fri, 14 Mar 2003 05:00:29 +0000 Subject: [PATCH 07/16] Bah, I thought Kent modified the MenuTunes class to accommodate the changes made to the remote API --- MenuTunes.h | 2 +- MenuTunes.m | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MenuTunes.h b/MenuTunes.h index 89223ed..2d3c5fa 100755 --- a/MenuTunes.h +++ b/MenuTunes.h @@ -38,7 +38,7 @@ int lastPlaylistIndex; BOOL isPlayingRadio; - ITMTRemotePlayerRunningStatus isAppRunning; + ITMTRemotePlayerRunningState isAppRunning; BOOL didHaveAlbumName; BOOL didHaveArtistName; //Helper variable for creating the menu diff --git a/MenuTunes.m b/MenuTunes.m index d2fdaf2..3c96ed0 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -44,7 +44,7 @@ menu = [[NSMenu alloc] initWithTitle:@""]; - if ( ( [currentRemote playerRunningStatus] == ITMTRemotePlayerRunning ) ) { + if ( ( [currentRemote playerRunningState] == ITMTRemotePlayerRunning ) ) { [self remotePlayerLaunched:nil]; } else { [self remotePlayerTerminated:nil]; @@ -607,9 +607,9 @@ - (void)timerUpdate { int playlist = [currentRemote currentPlaylistIndex]; - ITMTRemotePlayerState playerState = [currentRemote playerState]; + ITMTRemotePlayerPlayingState playerPlayingState = [currentRemote playerPlayingState]; - if ((playlist > 0) || playerState != ITMTRemotePlayerStopped) { + if ((playlist > 0) || playerPlayingState != ITMTRemotePlayerStopped) { int trackPlayingIndex = [currentRemote currentSongIndex]; if (trackPlayingIndex != lastSongIndex) { @@ -668,7 +668,7 @@ } //Update Play/Pause menu item if (playPauseMenuItem){ - if (playerState == ITMTRemotePlayerPlaying) { + if (playerPlayingState == ITMTRemotePlayerPlaying) { [playPauseMenuItem setTitle:@"Pause"]; } else { [playPauseMenuItem setTitle:@"Play"]; @@ -799,7 +799,7 @@ - (void)playPause:(id)sender { - ITMTRemotePlayerState state = [currentRemote playerState]; + ITMTRemotePlayerPlayingState state = [currentRemote playerPlayingState]; if (state == ITMTRemotePlayerPlaying) { [currentRemote pause]; -- 2.20.1 From cefefd3e817015f9b8e5708bedc52539cfa88799 Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Fri, 14 Mar 2003 07:13:08 +0000 Subject: [PATCH 08/16] Added methods for shuffle and repeat modes. --- ITMTRemote.h | 62 ++++++++++++++++++++++++++++++++++++++------------ ITMTRemote.m | 20 ++++++++++++++++ iTunesRemote.m | 20 ++++++++++++++++ 3 files changed, 88 insertions(+), 14 deletions(-) diff --git a/ITMTRemote.h b/ITMTRemote.h index 57a3228..b65b2d1 100755 --- a/ITMTRemote.h +++ b/ITMTRemote.h @@ -22,12 +22,12 @@ #import /*! - @enum ITMTRemotePlayerRunningState - @abstract Possible running states for the remote's player. - @discussion Used in fuctions that report or take the running state of the remote's player application. - @constant ITMTRemotePlayerNotRunning The remote's player isn't running. - @constant ITMTRemotePlayerLaunching The remote's player is starting up, or is running, but not yet accepting remote commands. - @constant ITMTRemotePlayerRunning The remote's player is running, and as such, is accepting remote commands. + * @enum ITMTRemotePlayerRunningState + * @abstract Possible running states for the remote's player. + * @discussion Used in fuctions that report or take the running state of the remote's player application. + * @constant ITMTRemotePlayerNotRunning The remote's player isn't running. + * @constant ITMTRemotePlayerLaunching The remote's player is starting up, or is running, but not yet accepting remote commands. + * @constant ITMTRemotePlayerRunning The remote's player is running, and as such, is accepting remote commands. */ typedef enum { ITMTRemotePlayerNotRunning = -1, @@ -36,14 +36,14 @@ typedef enum { } ITMTRemotePlayerRunningState; /*! - @enum ITMTRemotePlayerPlayingState - @abstract Possible playing states for the remote's player. - @discussion Used in functions that report or take the playing state of the remote's player application. - @constant ITMTRemotePlayerStopped The remote's player is stopped. - @constant ITMTRemotePlayerPaused The remote's player is paused. - @constant ITMTRemotePlayerPlaying The remote's player is playing. - @constant ITMTRemotePlayerRewinding The remote's player is rewinding. - @constant ITMTRemotePlayerForwarding The remote's player is forwarding. + * @enum ITMTRemotePlayerPlayingState + * @abstract Possible playing states for the remote's player. + * @discussion Used in functions that report or take the playing state of the remote's player application. + * @constant ITMTRemotePlayerStopped The remote's player is stopped. + * @constant ITMTRemotePlayerPaused The remote's player is paused. + * @constant ITMTRemotePlayerPlaying The remote's player is playing. + * @constant ITMTRemotePlayerRewinding The remote's player is rewinding. + * @constant ITMTRemotePlayerForwarding The remote's player is forwarding. */ typedef enum { ITMTRemotePlayerStopped = -1, @@ -53,6 +53,20 @@ typedef enum { ITMTRemotePlayerForwarding } ITMTRemotePlayerPlayingState; +/*! + * @enum ITMTRemotePlayerRepeatMode + * @abstract Possible repeat modes for the remote's player. + * @discussion Used in functions that report or set the remote's player's repeat mode. + * @constant ITMTRemotePlayerRepeatOff The player plays all of the songs in a playlist through to the end, and then stops. + * @constant ITMTRemotePlayerRepeatAll The player plays all of the songs in a playlist through to the end, and then starts over again from the beginning. + * @constant ITMTRemotePlayerRepeatOne The player loops playing the selected song. + */ +typedef enum { + ITMTRemotePlayerRepeatOff = -1, + ITMTRemotePlayerRepeatAll, + ITMTRemotePlayerRepeatOne +} ITMTRemotePlayerRepeatMode; + /*! * @protocol ITMTRemote * @discussion The Objective-C protocol which all MenuTunes remotes must implement. @@ -249,6 +263,26 @@ typedef enum { */ - (BOOL)setVolume:(float)volume; +/*! + * @method shuffleEnabled + */ +- (BOOL)shuffleEnabled; + +/*! + * @method setShuffleEnabled: + */ +- (BOOL)setShuffleEnabled:(BOOL)enabled; + +/*! + * @method repeatMode + */ +- (ITMTRemotePlayerRepeatMode)repeatMode; + +/*! + * @method setRepeatMode: + */ +- (BOOL)setRepeatMode:(ITMTRemotePlayerRepeatMode)repeatMode; + /*! * @method play */ diff --git a/ITMTRemote.m b/ITMTRemote.m index 72bd8df..d2f2ccc 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -157,6 +157,26 @@ return NO; } +- (BOOL)shuffleEnabled +{ + return NO; +} + +- (BOOL)setShuffleEnabled:(BOOL)enabled +{ + return NO; +} + +- (ITMTRemotePlayerRepeatMode)repeatMode +{ + return ITMTRemotePlayerRepeatOff; +} + +- (BOOL)setRepeatMode:(ITMTRemotePlayerRepeatMode)repeatMode +{ + return NO; +} + - (BOOL)play { return NO; diff --git a/iTunesRemote.m b/iTunesRemote.m index a5a1f82..0a02b1b 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -237,6 +237,26 @@ return NO; } +- (BOOL)shuffleEnabled +{ + return NO; +} + +- (BOOL)setShuffleEnabled:(BOOL)enabled +{ + return NO; +} + +- (ITMTRemotePlayerRepeatMode)repeatMode +{ + return ITMTRemotePlayerRepeatOff; +} + +- (BOOL)setRepeatMode:(ITMTRemotePlayerRepeatMode)repeatMode +{ + return NO; +} + - (BOOL)play { [[ITAppleEventCenter sharedCenter] sendAEWithEventClass:@"hook" eventID:@"Play" appPSN:iTunesPSN]; -- 2.20.1 From fe7df02d208eb352ec57213e89545f28212fba8a Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Fri, 14 Mar 2003 19:48:21 +0000 Subject: [PATCH 09/16] Added capabilities NSDictionary prototype, as well as a completed one for iTunesRemote. --- ITMTRemote.m | 14 +++++++++++++- iTunesRemote.m | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ITMTRemote.m b/ITMTRemote.m index d2f2ccc..8092d3e 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -44,7 +44,19 @@ - (NSDictionary *)capabilities { - return nil; + return [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool: NO], @"Remote", // Set this to YES for a valid remote, otherwise the remote will be unusable. + [NSNumber numberWithBool: NO], @"Basic Track Control", + [NSNumber numberWithBool: NO], @"Track Information", + [NSNumber numberWithBool: NO], @"Track Navigation", + [NSNumber numberWithBool: NO], @"Upcoming Songs", + [NSNumber numberWithBool: NO], @"Playlists", + [NSNumber numberWithBool: NO], @"Volume", + [NSNumber numberWithBool: NO], @"Shuffle", + [NSNumber numberWithBool: NO], @"Repeat Modes", + [NSNumber numberWithBool: NO], @"Equalizer", + [NSNumber numberWithBool: NO], @"Track Rating", + nil]; } - (ITMTRemotePlayerRunningState)playerRunningState diff --git a/iTunesRemote.m b/iTunesRemote.m index 0a02b1b..ce496f8 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -54,7 +54,19 @@ - (NSDictionary *)capabilities { - return nil; + return [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool: YES], @"Remote", + [NSNumber numberWithBool: YES], @"Basic Track Control", + [NSNumber numberWithBool: YES], @"Track Information", + [NSNumber numberWithBool: YES], @"Track Navigation", + [NSNumber numberWithBool: YES], @"Upcoming Songs", + [NSNumber numberWithBool: YES], @"Playlists", + [NSNumber numberWithBool: YES], @"Volume", + [NSNumber numberWithBool: YES], @"Shuffle", + [NSNumber numberWithBool: YES], @"Repeat Modes", + [NSNumber numberWithBool: YES], @"Equalizer", + [NSNumber numberWithBool: YES], @"Track Rating", + nil]; } - (ITMTRemotePlayerRunningState)playerRunningState -- 2.20.1 From 3d615cbf911616cc72a237911377daa98dc1b287 Mon Sep 17 00:00:00 2001 From: Alexander Strange Date: Sat, 15 Mar 2003 17:25:31 +0000 Subject: [PATCH 10/16] Finished everything but 'equalizer enabled' --- iTunesRemote.m | 58 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/iTunesRemote.m b/iTunesRemote.m index ce496f8..35256b4 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -129,11 +129,14 @@ { int realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; - if (realResult == 'cRTP') { - return @"radio tuner playlist"; - } else { - return @"playlist"; - } + switch (realResult) + { + case 'cRTP': + return @"radio tuner playlist"; + break; + default: + return @"playlist"; + } } - (int)currentPlaylistIndex @@ -200,7 +203,7 @@ - (BOOL)setCurrentSongRating:(float)rating { - [[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]; + [[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]; return YES; } @@ -251,22 +254,57 @@ - (BOOL)shuffleEnabled { - return NO; + int result = [[ITAppleEventCenter sharedCenter] + sendTwoTierAEWithRequestedKeyForNumber:@"pShf" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + return result; } - (BOOL)setShuffleEnabled:(BOOL)enabled { - return NO; + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu) ----:obj { form:'prop', want:type('prop'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }",enabled] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; } - (ITMTRemotePlayerRepeatMode)repeatMode { - return ITMTRemotePlayerRepeatOff; + FourCharCode m00f; + int result; + m00f = [[ITAppleEventCenter sharedCenter] + sendTwoTierAEWithRequestedKeyForNumber:@"pRpt" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]; + + switch (m00f) + { + case 'kRp0': + result = ITMTRemotePlayerRepeatOff; + break; + case 'kRp1': + result = ITMTRemotePlayerRepeatOne; + break; + case 'kRpA': + result = ITMTRemotePlayerRepeatAll; + break; + } + + return result; } - (BOOL)setRepeatMode:(ITMTRemotePlayerRepeatMode)repeatMode { - return NO; + FourCharCode m00f; + switch (repeatMode) + { + case ITMTRemotePlayerRepeatOff: + m00f = 'kRp0'; + break; + case ITMTRemotePlayerRepeatOne: + m00f = 'kRp1'; + break; + case ITMTRemotePlayerRepeatAll: + m00f = 'kRpA'; + break; + } + + [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu) ----:obj { form:'prop', want:type('pRpt'), seld:type('pShf'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }",m00f] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; + } - (BOOL)play -- 2.20.1 From efd57bc799aac892be3c161826168729b0419fb4 Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Sat, 15 Mar 2003 17:33:48 +0000 Subject: [PATCH 11/16] Quick Remote API update for an enumeration of all supported playlist classes. --- ITMTRemote.h | 18 +++++++++++++++++- ITMTRemote.m | 2 +- iTunesRemote.m | 8 +++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ITMTRemote.h b/ITMTRemote.h index b65b2d1..137b859 100755 --- a/ITMTRemote.h +++ b/ITMTRemote.h @@ -53,6 +53,22 @@ typedef enum { ITMTRemotePlayerForwarding } ITMTRemotePlayerPlayingState; +/*! + * @enum ITMTRemotePlayerPlaylistClass + * @abstract Possible playlist classes used by a remote's player + * @discussion Used in functions that report the class of a playlist to MenuTunes. While we borrow the terms/descriptions from iTunes, these should work fine with any other player. If your player doesn't support a given type of playlist, then just return ITMTRemotePlayerPlaylist. + * @constant ITMTRemotePlayerLibraryPlaylist For players that have one playlist that contains all of a user's music, or for players that don't have the concept of multiple playlists, this is the class for that "Master" list. + * @constant ITMTRemotePlayerPlaylist The generic playlist. Created and maintained by the user. + * @constant ITMTRemotePlayerSmartPlaylist A smart playlist is a playlist who's contents are dynamic, based on a set of criteria or updated by a script. These are usually not edited directly by the user, but instead maintained by the player. + * @constant ITMTRemotePlayerRadioPlaylist This is for when playing tracks off of (online) radio stations. + */ +typedef enum { + ITMTRemotePlayerLibraryPlaylist = -1, + ITMTRemotePlayerPlaylist, + ITMTRemotePlayerSmartPlaylist, + ITMTRemotePlayerRadioPlaylist +} ITMTRemotePlayerPlaylistClass; + /*! * @enum ITMTRemotePlayerRepeatMode * @abstract Possible repeat modes for the remote's player. @@ -176,7 +192,7 @@ typedef enum { /*! * @method classOfPlaylistAtIndex: */ -- (NSString *)classOfPlaylistAtIndex:(int)index; +- (ITMTRemotePlayerPlaylistClass)classOfPlaylistAtIndex:(int)index; /*! * @method currentPlaylistIndex diff --git a/ITMTRemote.m b/ITMTRemote.m index 8092d3e..8753f6d 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -79,7 +79,7 @@ return nil; } -- (NSString *)classOfPlaylistAtIndex:(int)index +- (ITMTRemotePlayerPlaylistClass)classOfPlaylistAtIndex:(int)index { return nil; } diff --git a/iTunesRemote.m b/iTunesRemote.m index 35256b4..b14f74e 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -125,17 +125,19 @@ return [[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:iTunesPSN]; } -- (NSString *)classOfPlaylistAtIndex:(int)index +- (ITMTRemotePlayerPlaylistClass)classOfPlaylistAtIndex:(int)index { 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 'cRTP': - return @"radio tuner playlist"; + return ITMTRemotePlayerRadioPlaylist; break; default: - return @"playlist"; + return ITMTRemotePlayerPlaylist; } } -- 2.20.1 From 64c4e21e6550d32210f20393d1d8249d7947bc71 Mon Sep 17 00:00:00 2001 From: Alexander Strange Date: Sat, 15 Mar 2003 17:47:40 +0000 Subject: [PATCH 12/16] KLWONZ --- iTunesRemote.m | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/iTunesRemote.m b/iTunesRemote.m index b14f74e..7ab8dfd 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -129,10 +129,11 @@ { 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 ITRemotePlayerLibraryPlaylist; case 'cRTP': return ITMTRemotePlayerRadioPlaylist; break; @@ -143,9 +144,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 @@ -155,9 +154,7 @@ - (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,10 +194,8 @@ - (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 @@ -211,12 +206,13 @@ - (BOOL)equalizerEnabled { - return NO; + return [[ITAppleEventCenter sharedCenter] + sendAEWithRequestedKeyForNumber:@"pEQ " 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:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } }",enabled] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; } - (NSArray *)eqPresets -- 2.20.1 From e4c45eacd7168f01097aeb8975a0b5825714a58d Mon Sep 17 00:00:00 2001 From: Alexander Strange Date: Sat, 15 Mar 2003 18:49:28 +0000 Subject: [PATCH 13/16] Compiles more --- iTunesRemote.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iTunesRemote.m b/iTunesRemote.m index 7ab8dfd..eb8fa7e 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -133,7 +133,7 @@ switch (realResult) { case 'cLiP': - return ITRemotePlayerLibraryPlaylist; + return ITMTRemotePlayerLibraryPlaylist; case 'cRTP': return ITMTRemotePlayerRadioPlaylist; break; -- 2.20.1 From dd401fbf4c409df6e0a9c291fefca06bcfd87d31 Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Sun, 16 Mar 2003 00:24:31 +0000 Subject: [PATCH 14/16] Song rating stuff back in programatically. No stars yet ;( --- English.lproj/MainMenu.nib/classes.nib | 4 +- English.lproj/MainMenu.nib/info.nib | 9 ----- MenuTunes.h | 9 +++-- MenuTunes.m | 55 +++++++++++++------------- 4 files changed, 35 insertions(+), 42 deletions(-) diff --git a/English.lproj/MainMenu.nib/classes.nib b/English.lproj/MainMenu.nib/classes.nib index b342736..eda69cc 100755 --- a/English.lproj/MainMenu.nib/classes.nib +++ b/English.lproj/MainMenu.nib/classes.nib @@ -3,10 +3,10 @@ {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, {CLASS = MTApplication; LANGUAGE = ObjC; SUPERCLASS = NSApplication; }, { - ACTIONS = {setSongRating = id; }; + ACTIONS = {}; CLASS = MenuTunes; LANGUAGE = ObjC; - OUTLETS = {ratingMenu = NSMenu; }; + OUTLETS = {}; SUPERCLASS = NSObject; } ); diff --git a/English.lproj/MainMenu.nib/info.nib b/English.lproj/MainMenu.nib/info.nib index 2d71d80..adeae52 100755 --- a/English.lproj/MainMenu.nib/info.nib +++ b/English.lproj/MainMenu.nib/info.nib @@ -2,17 +2,8 @@ - IBEditorPositions - - 198 - 106 271 72 120 0 0 1152 746 - IBFramework Version 291.0 - IBOpenObjects - - 198 - IBSystem Version 6I32 diff --git a/MenuTunes.h b/MenuTunes.h index 2d3c5fa..393c5ec 100755 --- a/MenuTunes.h +++ b/MenuTunes.h @@ -24,8 +24,6 @@ @interface MenuTunes : NSObject { - IBOutlet NSMenu *ratingMenu; - ITStatusItem *statusItem; NSMenu *menu; ITMTRemote *currentRemote; @@ -54,7 +52,10 @@ NSMenuItem *eqItem; NSMenu *eqMenu; - NSMenuItem *songRatingMenuItem; //Song Rating submenu item + //For song ratings + NSMenuItem *songRatingMenuItem; + NSMenu *ratingMenu; + NSMenuItem *playPauseMenuItem; //Toggle between 'Play' and 'Pause' PreferencesController *prefsController; @@ -69,7 +70,7 @@ - (void)runTimerInNewThread; -- (IBAction)setSongRating:(id)sender; +- (void)setSongRating:(id)sender; - (void)clearHotKeys; - (void)closePreferences; diff --git a/MenuTunes.m b/MenuTunes.m index 3c96ed0..eea31d2 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -280,9 +280,31 @@ action:nil keyEquivalent:@""]; } else if ([item isEqualToString:@"Song Rating"]) { + NSMenuItem *item; + int i; + NSString *curTitle = @"....."; + songRatingMenuItem = [menu addItemWithTitle:@"Song Rating" action:nil keyEquivalent:@""]; + + ratingMenu = [[NSMenu alloc] initWithTitle:@""]; + + item = [ratingMenu addItemWithTitle:@"....." + action:@selector(setSongRating:) + keyEquivalent:@""]; + [item setTarget:self]; + [item setTag:0]; + + for (i = 1; i < 6; i++) { + curTitle = [curTitle substringToIndex:4]; + curTitle = [@"x" stringByAppendingString:curTitle]; + item = [ratingMenu addItemWithTitle:curTitle + action:@selector(setSongRating:) + keyEquivalent:@""]; + [item setTarget:self]; + [item setTag:(i * 20)]; + } } else if ([item isEqualToString:@""]) { [menu addItem:[NSMenuItem separatorItem]]; } @@ -372,31 +394,11 @@ if (songRatingMenuItem) { int rating = (int)[currentRemote currentSongRating] * 10; int i; - for (i = 0; i < 5; i++) { [[ratingMenu itemAtIndex:i] setState:NSOffState]; + [[ratingMenu itemAtIndex:i] setTarget:self]; } - - switch (rating) { - case 0: - [[ratingMenu itemAtIndex:5] setState:NSOnState]; - break; - case 2: - [[ratingMenu itemAtIndex:4] setState:NSOnState]; - break; - case 4: - [[ratingMenu itemAtIndex:3] setState:NSOnState]; - break; - case 6: - [[ratingMenu itemAtIndex:2] setState:NSOnState]; - break; - case 8: - [[ratingMenu itemAtIndex:1] setState:NSOnState]; - break; - case 10: - [[ratingMenu itemAtIndex:0] setState:NSOnState]; - break; - } + [[ratingMenu itemAtIndex:rating / 2] setState:NSOnState]; } } @@ -614,7 +616,7 @@ if (trackPlayingIndex != lastSongIndex) { BOOL wasPlayingRadio = isPlayingRadio; - isPlayingRadio = [[currentRemote classOfPlaylistAtIndex:playlist] isEqualToString:@"radio tuner playlist"]; + isPlayingRadio = ([currentRemote classOfPlaylistAtIndex:playlist] == ITMTRemotePlayerRadioPlaylist); if (isPlayingRadio && !wasPlayingRadio) { int i; @@ -637,7 +639,7 @@ } else { if (playlist != lastPlaylistIndex) { BOOL wasPlayingRadio = isPlayingRadio; - isPlayingRadio = [[currentRemote classOfPlaylistAtIndex:playlist] isEqualToString:@"radio tuner playlist"]; + isPlayingRadio = ([currentRemote classOfPlaylistAtIndex:playlist] == ITMTRemotePlayerRadioPlaylist); if (isPlayingRadio && !wasPlayingRadio) { int i; @@ -736,7 +738,7 @@ { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; - refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES] retain]; + refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES] retain]; [runLoop run]; [pool release]; } @@ -771,7 +773,6 @@ - (void)playTrack:(id)sender { [currentRemote switchToSongAtIndex:[[sender representedObject] intValue]]; - [self updateMenu]; } - (void)selectPlaylist:(id)sender @@ -840,7 +841,7 @@ [currentRemote setEqualizerEnabled:![currentRemote equalizerEnabled]]; } -- (IBAction)setSongRating:(id)sender +- (void)setSongRating:(id)sender { NSLog(@"%f", [currentRemote currentSongRating]); NSLog(@"%f", (float)[sender tag] / 100.0); -- 2.20.1 From 41381a3e6391921379d5e1b78d5434d846cc07fa Mon Sep 17 00:00:00 2001 From: Alexander Strange Date: Sun, 16 Mar 2003 00:46:19 +0000 Subject: [PATCH 15/16] M0nk3ys --- iTunesRemote.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/iTunesRemote.m b/iTunesRemote.m index eb8fa7e..59bffe1 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -134,6 +134,7 @@ { case 'cLiP': return ITMTRemotePlayerLibraryPlaylist; + break; case 'cRTP': return ITMTRemotePlayerRadioPlaylist; break; @@ -200,7 +201,7 @@ - (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:'prop', want:type('prop'), seld:type('pTrk'), from:'null'() } }",(long)rating*100] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN]; return YES; } -- 2.20.1 From 479952e2cf104d1f984108c5b672d8fbb039eebe Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Sun, 16 Mar 2003 06:06:06 +0000 Subject: [PATCH 16/16] w00t. If player application is not running, instead of simply saying so, MenuTunes provides the user with a quick item to launch the player. --- ITMTRemote.h | 5 +++++ ITMTRemote.m | 5 +++++ MenuTunes.h | 2 ++ MenuTunes.m | 15 +++++++++++++-- iTunesRemote.m | 5 +++++ 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ITMTRemote.h b/ITMTRemote.h index 137b859..07dec73 100755 --- a/ITMTRemote.h +++ b/ITMTRemote.h @@ -166,6 +166,11 @@ typedef enum { */ - (NSDictionary *)capabilities; +/*! + * @method showPrimaryInterface + */ +- (BOOL)showPrimaryInterface; + /*! * @method playerRunningState * @abstract Returns the running state of the remote's player. diff --git a/ITMTRemote.m b/ITMTRemote.m index 8753f6d..50fcb21 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -59,6 +59,11 @@ nil]; } +- (BOOL)showPrimaryInterface +{ + return NO; +} + - (ITMTRemotePlayerRunningState)playerRunningState { return nil; diff --git a/MenuTunes.h b/MenuTunes.h index 393c5ec..e45925a 100755 --- a/MenuTunes.h +++ b/MenuTunes.h @@ -75,4 +75,6 @@ - (void)clearHotKeys; - (void)closePreferences; +- (void)showPlayer; + @end diff --git a/MenuTunes.m b/MenuTunes.m index eea31d2..0c08e20 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -749,8 +749,7 @@ [menu release]; menu = [[NSMenu alloc] initWithTitle:@""]; - [menu addItemWithTitle:@"Audio Player" action:NULL keyEquivalent:@""]; - [menu addItemWithTitle:@"Not Running" action:NULL keyEquivalent:@""]; + [[menu addItemWithTitle:[NSString stringWithFormat:@"Open %@", [currentRemote playerSimpleName]] action:@selector(showPlayer:) keyEquivalent:@""] setTarget:self]; [menu addItem:[NSMenuItem separatorItem]]; [[menu addItemWithTitle:@"Preferences" action:@selector(showPreferences:) keyEquivalent:@""] setTarget:self]; [[menu addItemWithTitle:@"Quit" action:@selector(quitMenuTunes:) keyEquivalent:@""] setTarget:self]; @@ -875,6 +874,18 @@ prefsController = nil; } +- (void)showPlayer:(id)sender +{ + if ( ( isAppRunning == ITMTRemotePlayerRunning) ) { + [currentRemote showPrimaryInterface]; + } else { + if (![[NSWorkspace sharedWorkspace] launchApplication:[currentRemote playerFullName]]) { + NSLog(@"Error Launching Player"); + } + } +} + + // // // Show Current Track Info And Show Upcoming Songs Floaters diff --git a/iTunesRemote.m b/iTunesRemote.m index 59bffe1..e286598 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -69,6 +69,11 @@ nil]; } +- (BOOL)showPrimaryInterface +{ + return NO; +} + - (ITMTRemotePlayerRunningState)playerRunningState { NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; -- 2.20.1