Re: No track index in iTunes SB?
Re: No track index in iTunes SB?
- Subject: Re: No track index in iTunes SB?
- From: has <email@hidden>
- Date: Mon, 10 Mar 2008 16:14:23 +0000
slasktrattenator wrote:
Anyone know how to get the index of the current iTunes track using
Scripting Bridge? With Applescript, it's as simple as "tell iTunes to
return index of current track", but iTunes SB has no such property
(well, there is one, but it only refers to the index of the current
playlist). It seems the iTunesTrack index property is simply
missing...? Or am I missing something?
You'll have to muck about with raw AE codes if you want to do it with
Scripting Bridge; see past discussions of SB's design flaws for more
info.
Here's how you do it using objc-appscript <http://appscript.sourceforge.net/objc-appscript/
>, which works much more like AppleScript so is much less prone to
these sorts of application compatibility problems:
#import "ITGlue/ITGlue.h"
// To create iTunes glue: osaglue -o ITGlue -p IT iTunes
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
ITApplication *itunes = [[ITApplication alloc] initWithBundleID:
@"com.apple.itunes"];
ITReference *ref = [[itunes currentTrack] index];
NSError *err;
NSNumber *index = [[ref get] sendWithError: &err];
if (index)
NSLog(@"Now playing track %@", index);
else
NSLog(@"%@", err);
[itunes release];
[pool drain];
return 0;
}
HTH
has
--
Control AppleScriptable applications
from Python, Ruby and ObjC:
http://appscript.sourceforge.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden