FROM : Steven Degutis
DATE : Sun Mar 02 13:54:02 2008
Hannes,
I haven't heard of this ITApplication before, but for your specific
problem, I think it's clear why [currentTrack
isKindOfClass:[iTunesFileTrack class]] evaluates to true: in the
previous line, you defined it as such, like this:
iTunesTrack *currentTrack = [iTunes currentTrack];
So obviously it is an iTunesTrack!
Try this:
iTunesFileTrack *currentTrack = [iTunesFileTrack currentTrack];
NSLog(@"%@", [currentTrack location]);
Since iTunesFileTrack is a subclass of iTunesTrack, it should work,
giving you the info you need.
On Sun, Mar 2, 2008 at 6:05 AM, has <hengist.<email_removed>> wrote:
> 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
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
DATE : Sun Mar 02 13:54:02 2008
Hannes,
I haven't heard of this ITApplication before, but for your specific
problem, I think it's clear why [currentTrack
isKindOfClass:[iTunesFileTrack class]] evaluates to true: in the
previous line, you defined it as such, like this:
iTunesTrack *currentTrack = [iTunes currentTrack];
So obviously it is an iTunesTrack!
Try this:
iTunesFileTrack *currentTrack = [iTunesFileTrack currentTrack];
NSLog(@"%@", [currentTrack location]);
Since iTunesFileTrack is a subclass of iTunesTrack, it should work,
giving you the info you need.
On Sun, Mar 2, 2008 at 6:05 AM, has <hengist.<email_removed>> wrote:
> 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
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| Hannes Petri | Mar 2, 02:28 | |
| Jonathan 'Wolf' Re… | Mar 2, 06:06 | |
| has | Mar 2, 13:05 | |
| Steven Degutis | Mar 2, 13:54 | |
| has | Mar 3, 00:02 | |
| Adam P Jenkins | Mar 3, 00:16 | |
| Adam P Jenkins | Mar 3, 00:40 | |
| has | Mar 3, 01:44 | |
| Jens Alfke | Mar 3, 07:32 | |
| has | Mar 3, 16:21 | |
| Steven Degutis | Mar 3, 16:27 | |
| Christopher Nebel | Mar 3, 21:22 | |
| has | Mar 3, 22:45 |






Cocoa mail archive

