Some more work on the iTunes remote... I'm starting to require testing,
authorJoseph Spiros <joseph.spiros@ithinksw.com>
Sat, 6 Sep 2003 22:26:59 +0000 (22:26 +0000)
committerJoseph Spiros <joseph.spiros@ithinksw.com>
Sat, 6 Sep 2003 22:26:59 +0000 (22:26 +0000)
so less work will be done on the iTunes remote until the MT application
uses remotes that use the new API.

iTunesPlayer.h
iTunesPlayer.m
iTunesPlaylist.h
iTunesPlaylist.m
iTunesTrack.h [new file with mode: 0755]
iTunesTrack.m [new file with mode: 0755]

index 59e0e54..ab8505b 100755 (executable)
@@ -7,7 +7,7 @@
 //
 
 #import <Cocoa/Cocoa.h>
-
+#import <ITFoundation/ITFoundation.h>
 #import <ITMTRemote/ITMTRemote.h>
 
 @interface iTunesPlayer : ITMTPlayer <ITMTPlayer> {
index cb6eb94..1c7f225 100755 (executable)
@@ -47,12 +47,21 @@ static iTunesPlayer *_sharediTunesPlayer = nil;
 }
 
 - (ITMTPlaylist *)currentPlaylist {
-    // return dynamically from an AE
-    // (ie - [iTunesPlaylist playlistForIndex:<get index from an AE>]
+    int tIndex;
+    if ( ( tIndex = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pidx" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:savedPSN] ) ) {
+        return [iTunesPlaylist playlistWithIndex:tIndex];
+    } else {
+        return nil;
+    }
 }
 
 - (ITMTTrack *)currentTrack {
-    // return dynamically from an AE
+    int tDIndex;
+    if ( ( tDindex = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pDID" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:savedPSN] ) ) {
+        return [iTunesTrack trackWithDatabaseIndex:tDIndex];
+    } else {
+        return nil;
+    }
 }
 
 - (ITMTEqualizer *)currentEqualizer {
index 0a0d515..ae7ada9 100755 (executable)
@@ -9,8 +9,9 @@
 #import <Foundation/Foundation.h>
 
 
-@interface iTunesPlaylist : NSObject {
-
+@interface iTunesPlaylist : ITMTPlaylist <ITMTPlaylist> {
+    int                _index;
 }
-
++ (id)playlistWithIndex:(int)index;
+- (id)initWithIndex:(int)index;
 @end
index f571ba7..60c01a5 100755 (executable)
 
 @implementation iTunesPlaylist
 
-+ (id)playlistForIndex:(int)index {
++ (id)playlistWithIndex:(int)index {
+    return [[[iTunesPlaylist alloc] initWithIndex:index] autorelease];
+}
+
+- (id)initWithIndex:(int)index {
+    if ( ( self = [super init] ) ) {
+        _index = index;
+    }
+    return self;
 }
 
 @end
diff --git a/iTunesTrack.h b/iTunesTrack.h
new file mode 100755 (executable)
index 0000000..920c1fb
--- /dev/null
@@ -0,0 +1,17 @@
+//
+//  iTunesTrack.h
+//  MenuTunes
+//
+//  Created by Joseph Spiros on Sat Sep 06 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface iTunesTrack : ITMTTrack <ITMTTrack> {
+    int                _index;
+}
++ (id)trackWithDatabaseIndex:(int)index;
+- (id)initWithDatabaseIndex:(int)index;
+@end
diff --git a/iTunesTrack.m b/iTunesTrack.m
new file mode 100755 (executable)
index 0000000..7b3a813
--- /dev/null
@@ -0,0 +1,24 @@
+//
+//  iTunesTrack.m
+//  MenuTunes
+//
+//  Created by Joseph Spiros on Sat Sep 06 2003.
+//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
+//
+
+#import "iTunesTrack.h"
+
+@implementation iTunesTrack
+
++ (id)trackWithDatabaseIndex:(int)index {
+    return [[[iTunesTrack alloc] initWithIndex:index] autorelease];
+}
+
+- (id)initWithDatabaseIndex:(int)index {
+    if ( ( self = [super init] ) ) {
+        _index = index;
+    }
+    return self;
+}
+
+@end