Implemented running scripts on song change.
[MenuTunes.git] / iTunesRemote.m
index d41f3bd..7a0c9cb 100755 (executable)
 
 - (NSImage *)currentSongAlbumArt
 {
-    return nil;
+    NSAppleScript *script;
+    NSAppleEventDescriptor *moof;
+    NSData *data;
+    ITDebugLog(@"Getting current song album art.");
+    script = [[NSAppleScript alloc] initWithSource:@"tell application \"iTunes\"\nget data of artwork 1 of current track\nend tell"];
+    moof = [script executeAndReturnError:nil];
+    data = [moof data];
+    ITDebugLog(@"Getting current song album art done.");
+    if (data) {
+        return [[[NSImage alloc] initWithData:data] autorelease];
+    } else {
+        return nil;
+    }
 }
 
 - (float)currentSongRating