#import <Cocoa/Cocoa.h>
typedef enum {
- stopped = -1,
- paused,
- playing,
- rewinding,
- forwarding
+ ITMTRemotePlayerNotRunning = -1,
+ ITMTRemotePlayerLaunching,
+ ITMTRemotePlayerRunning
+} ITMTRemotePlayerRunningStatus;
+
+typedef enum {
+ ITMTRemotePlayerStopped = -1,
+ ITMTRemotePlayerPaused,
+ ITMTRemotePlayerPlaying,
+ ITMTRemotePlayerRewinding,
+ ITMTRemotePlayerForwarding
} ITMTRemotePlayerState;
/*! @protocol ITMTRemote
*/
+ (id)remote;
-/*! @method title:
+/*! @method pluginTitle:
* @abstract Returns the title of the plugin, which should be player name.
* @result An NSString containing the title.
*/
-- (NSString *)title;
+- (NSString *)pluginTitle;
-/*! @method description:
+/*! @method pluginInformation:
* @abstract Returns a description of the remote.
* @result An NSString containing the description.
*/
-- (NSString *)information;
+- (NSString *)pluginInformation;
-/*! @method icon:
+/*! @method pluginIcon:
* @abstract Returns a icon for the remote.
* @result An NSImage containing the icon.
*/
-- (NSImage *)icon;
+- (NSImage *)pluginIcon;
/*! @method begin:
* @abstract Sent when the plugin should begin operation.
*/
- (BOOL)halt;
-/*! @method isAppRunning:
+- (NSString *)playerFullName;
+
+- (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.
*/
-- (BOOL)isAppRunning;
+- (ITMTRemotePlayerRunningStatus)playerRunningStatus;
/*! @method playerState:
* @abstract Returns controlled application's playing state.
- (BOOL)pause;
- (BOOL)goToNextSong;
- (BOOL)goToPreviousSong;
-- (BOOL)fastForward;
+- (BOOL)forward;
- (BOOL)rewind;
- (BOOL)switchToPlaylistAtIndex:(int)index;
menu = [[NSMenu alloc] initWithTitle:@""];
- if ([currentRemote isAppRunning]) {
+ if ( ( [currentRemote remotePlayerStatus] == ITMTRemotePlayerRunning ) ) {
[self remotePlayerLaunched:nil];
} else {
[self remotePlayerTerminated:nil];
NSMenuItem *menuItem;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- if (!isAppRunning) {
+ if ( ( isAppRunning = ITMTRemotePlayerNotRunning ) ) {
return;
}
- (void)remotePlayerLaunched:(NSNotification *)note
{
- isAppRunning = YES;
+ isAppRunning = ITMTRemotePlayerRunning;
//Restart the timer
refreshTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES];
- (void)remotePlayerTerminated:(NSNotification *)note
{
- isAppRunning = NO;
+ isAppRunning = ITMTRemotePlayerNotRunning;
[menu release];
menu = [[NSMenu alloc] initWithTitle:@""];
- (void)closePreferences
{
- if (isAppRunning) {
+ if ( ( isAppRunning == ITMTRemotePlayerRunning) ) {
[self setupHotKeys];
}
[prefsController release];
return YES;
}
-- (BOOL)isAppRunning
+- (ITMTRemotePlayerRunningStatus)playerRunningStatus
{
NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications];
int i;
for (i = 0; i < count; i++) {
if ([[[apps objectAtIndex:i] objectForKey:@"NSApplicationName"]
isEqualToString:@"iTunes"]) {
- return YES;
+ return ITMTRemotePlayerRunning;
}
}
- return NO;
+ return ITMTRemotePlayerNotRunning;
}
- (ITMTRemotePlayerState)playerState
{
default:
case 'kPSS':
- return stopped;
+ return ITMTRemotePlayerStopped;
case 'kPSP':
- return playing;
+ return ITMTRemotePlayerPlaying;
case 'kPSp':
- return paused;
+ return ITMTRemotePlayerPaused;
case 'kPSR':
- return rewinding;
+ return ITMTRemotePlayerRewinding;
case 'kPSF':
- return forwarding;
+ return ITMTRemotePlayerForwarding;
}
return stopped;