changeset 368:d0c6a13ae6d2 macness

applescript to actually grab itunes current track
author Dan Stowell <dan.stowell@eecs.qmul.ac.uk>
date Tue, 12 Oct 2010 13:59:06 +0100
parents 726e1c1382f3
children 8b3038e55d50
files osx/svitunes.mm
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/osx/svitunes.mm	Tue Oct 12 13:04:50 2010 +0100
+++ b/osx/svitunes.mm	Tue Oct 12 13:59:06 2010 +0100
@@ -37,7 +37,22 @@
     NSAppleScript *scriptObject = [[NSAppleScript alloc]    initWithSource:@" \
 tell application \"System Events\" to set iTunesIsRunning to (name of processes) contains \"iTunes\" \n\
 if iTunesIsRunning is false then return \"\" \n\
-return \"twelve-bar blues track\""
+\
+tell application \"iTunes\" \n\
+    if player state is not stopped then \n\
+        set aTrack to current track \n\
+    else \n\
+        set sel to selection \n\
+        if sel is not {} then --and (length of sel) is 1 then \n\
+            set aTrack to item 1 of sel \n\
+        else \n\
+            return \"\" \n\
+        end if \n\
+    end if \n\
+    \
+    return the POSIX path of (location of aTrack as text) \n\
+end tell \n\
+"
     ];
     
     NSLog([scriptObject source]);