Hi Archseed,
I realized that it didn’t really matter, I just needed to uncheck everything on my image view in IB . So far it works fine.
Hi Archseed,
I realized that it didn’t really matter, I just needed to uncheck everything on my image view in IB . So far it works fine.
Jobu,
I have played a little with Cocoa and thought one of the golden rules was that is you created an object with alloc then you were resopnsible for releaseing it.
You don’t appear to release
[[NSAppleScript alloc] initWithSource
All the best
Terry
Absolutely. Every alloc/init or copy you should release should be paired with a release or an autorelease. I have changed both of my posts to reflect this, using an autorelease.
Thanks for pointing that out.
j
send it over, i’ll take a look.
spikeit_13 AT hotmail DOT com
alright its sent. thanks.
hey, i just emailed you back, but in case you dont check often, what exactly is your problem?
Hi everybody,
I’m playing with this script and it works fine if I want to display the artwork of current track.
is there a way to display the artwork of a different track?
what I did is:
tell application "iTunes"
set track_id to file track 1 whose album is item 1 of shortAlbumList
set al to album of track_id
set art to data of artwork 1 of track_id as picture
end tell
call method "displayArtworkInImageView:trackHasArtwork:" of class "ArtworkController" with parameters {track_id, imageView, (art is not missing value)}
but it doesn’t work.
I checked the ArtworkController.m and I noticed it this line:
…skip…
[center]NSAppleScript *aScript = [[[NSAppleScript alloc] initWithSource:@"tell application \"iTunes\"\n \
return (data of artwork 1 of current track) as picture\n \
end tell"] autorelease];[/center]
… skip …
so I tried to change it to:
[center]NSAppleScript *aScript = [[[NSAppleScript alloc] initWithSource:@"tell application \"iTunes\"\n \
return (data of artwork 1 of track_id) as picture\n \
end tell"] autorelease];[/center]
but no luck.
How can I pass the variable track_id (which contains something like
track id 4967 of library playlist id 3838 of source id 42 of application “iTunes”
to the ArtworkController???
Thanks a lot,
Max
Hi,
you can’t pass an object like a file track of iTunes, but you can pass the unique database ID of the track
tell application "iTunes"
set track_id to file track 1 whose album is item 1 of shortAlbumList
set al to album of track_id
set dbID to database ID of track_id
set art to data of artwork 1 of track_id as picture
end tell
call method "displayArtworkInImageView:ofTrack:trackHasArtwork:" of class "ArtworkController" with parameters {imageView, dbID, (art is not missing value)}
[code]+ (void)displayArtworkInImageView:(NSImageView *)theImageView
ofTrack:(int)databaseID
trackHasArtwork:(BOOL)hasArtwork {
NSImage *image;
if (hasArtwork) {
NSString *aScriptText = [NSString stringWithFormat:@“tell application "iTunes"\nreturn (data of artwork 1 of (first track whose database ID is %i)) as picture\nend tell”, databaseID];
NSAppleScript *aScript = [[[NSAppleScript alloc] initWithSource:aScriptText] autorelease];
NSData *rawData = [[aScript executeAndReturnError:nil] data];
image = [[[NSImage alloc] initWithData:rawData] autorelease];
}
else {
/* Use a default image located in your app resources */
image = [NSImage imageNamed:@"NoArtwork.png"];
/* Use no image when no artwork exists */
//image = nil;
}
[theImageView setImage:image];
}[/code]
thanks a lot, it works perfectly.
Max