Skip navigation.
 
mlRe: Problems with ScriptingBridge and iTunes
FROM : has
DATE : Sun Mar 02 13:05:28 2008

Hannes Petri wrote:

> I want to retrieve the path to the currently played file in iTunes. I
> thought scripting bridge would be the perfect tool for this, however
> i've run into some problem. I have this code:
>
> iTunesApplication *iTunes = [[SBApplication alloc]
> initWithBundleIdentifier:@"com.apple.iTunes"];
> iTunesTrack *currentTrack = [iTunes currentTrack];
>     
> if ([currentTrack isKindOfClass:[iTunesFileTrack class]]) {
>     
>
> }
>
> The problem is, that the class of the object returned is _always_
> iTunesTrack, and not iTunesFileTrack, as i expect it to be.


Here's how you'd do it using objc-appscript <http://appscript.sourceforge.net/objc-appscript.html
>:


// To generate iTunes glue: osaglue  -o ITGlue  -p IT  iTunes

#import <Foundation/Foundation.h>
#import "ITGlue/ITGlue.h"

int main (int argc, const char * argv[]) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   ITApplication *itunes = [[ITApplication alloc] initWithBundleID: 
@"com.apple.itunes"];
   ITReference *track = [itunes currentTrack];
   
   ITConstant *trackClass = [[[track class_] get] send];
   
   if (trackClass == [ITConstant fileTrack]) {
       ASAlias *trackFile = [[[track location] get] send];
       NSLog(@"%@", trackFile);
   }
   [itunes release];
   [pool drain];
   return 0;
}

HTH

has
--
http://appscript.sourceforge.net

Related mailsAuthorDate
mlProblems with ScriptingBridge and iTunes Hannes Petri Mar 2, 02:28
mlRe: Problems with ScriptingBridge and iTunes Jonathan 'Wolf' Re… Mar 2, 06:06
mlRe: Problems with ScriptingBridge and iTunes has Mar 2, 13:05
mlRe: Problems with ScriptingBridge and iTunes Steven Degutis Mar 2, 13:54
mlRe: Problems with ScriptingBridge and iTunes has Mar 3, 00:02
mlRe: Problems with ScriptingBridge and iTunes Adam P Jenkins Mar 3, 00:16
mlRe: Problems with ScriptingBridge and iTunes Adam P Jenkins Mar 3, 00:40
mlRe: Problems with ScriptingBridge and iTunes has Mar 3, 01:44
mlRe: Problems with ScriptingBridge and iTunes Jens Alfke Mar 3, 07:32
mlRe: Problems with ScriptingBridge and iTunes has Mar 3, 16:21
mlRe: Problems with ScriptingBridge and iTunes Steven Degutis Mar 3, 16:27
mlRe: Problems with ScriptingBridge and iTunes Christopher Nebel Mar 3, 21:22
mlRe: Problems with ScriptingBridge and iTunes has Mar 3, 22:45