comparison osx/svitunes.mm @ 370:ca9f27734349 macness

svitunes: retrieve the genre metadata, as well as the path
author Dan Stowell <dan.stowell@eecs.qmul.ac.uk>
date Fri, 15 Oct 2010 11:07:11 +0100
parents d0c6a13ae6d2
children fad5611ef9db
comparison
equal deleted inserted replaced
369:8b3038e55d50 370:ca9f27734349
30 QString result = QString::fromUtf16(chars, range.length); 30 QString result = QString::fromUtf16(chars, range.length);
31 delete chars; 31 delete chars;
32 return result; 32 return result;
33 } 33 }
34 34
35 QString iTunesNowPlayingPath(){ 35 QStringList iTunesNowPlaying(){
36 NSDictionary *errorDict; 36 NSDictionary *errorDict;
37 NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:@" \ 37 NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:@" \
38 tell application \"System Events\" to set iTunesIsRunning to (name of processes) contains \"iTunes\" \n\ 38 tell application \"System Events\" to set iTunesIsRunning to (name of processes) contains \"iTunes\" \n\
39 if iTunesIsRunning is false then return \"\" \n\ 39 if iTunesIsRunning is false then return \"\" \n\
40 \ 40 \
48 else \n\ 48 else \n\
49 return \"\" \n\ 49 return \"\" \n\
50 end if \n\ 50 end if \n\
51 end if \n\ 51 end if \n\
52 \ 52 \
53 return the POSIX path of (location of aTrack as text) \n\ 53 return the POSIX path of (location of aTrack as text) & \"\n\" & (genre of aTrack) \n\
54 end tell \n\ 54 end tell \n\
55 " 55 "
56 ]; 56 ];
57 57
58 NSLog([scriptObject source]); 58 NSLog([scriptObject source]);
71 NSLog(nsResultString); 71 NSLog(nsResultString);
72 72
73 QString resultString = qt_mac_NSStringToQString(nsResultString); 73 QString resultString = qt_mac_NSStringToQString(nsResultString);
74 74
75 [scriptObject release]; 75 [scriptObject release];
76 return resultString; 76 return resultString.split(QChar('\n'));
77 } 77 }