Getting Album Artwork

Hey everyone. I’m currently trying to grab the album artwork of the currently playing song in iTunes with this code:

tell application "iTunes"
			set albArt to the data of artwork
		end tell

…but I am getting errors. That seems right, but apparently not. Any suggestions? Thanks!

Hi Masna,

of course you get errors :wink: Artwork is a list of elements and there is no reference which track you want to access

tell application "iTunes"
	set albArt to data of artwork 1 of track 1 of playlist "Library"
end tell

Ok, I changed that, but I’m still getting an error (a really, really, really long error of the sort “Can’t make data…”). Any idea? Thanks again.

Strange, it works on my machine, if there is an artwork,
maybe the reason is, I don’t have downloaded artworks (those which are stored externally),
all my artworks are in the audio files

I tried this to no avail:


tell application "iTunes"
	try
		set albDownBool to the downloaded of artwork 1 of track trackName of playlist "Music"
		if albDownBool is equal to false then
			set albArt to the data of artwork 1 of track trackName of playlist "Music"
		else
			set albArt to false
		end if
	end try
end tell

Any ideas?

Not really, your script works like a charm on my machine.
I recommend to approach step by step to isolate the error e.g.

tell application "iTunes" to get track trackName of playlist "Music"

then

tell application "iTunes" to get artwork 1 of track trackName of playlist "Music"

and watch the results in Script Editor

I feel dumb…

This is the issue:

set contents of image view "albumArt" of window "idoControl" to albArt

Did I write that incorrectly?

I had had set image of image view… but that didn’t work either.

We’re talking about Xcode, doesn’t we? :wink:

You have to load the picture and then set the image with this syntax:

set theImage to load image Imagepath
set image of image view "albumArt" of window "idoControl" to theImage

The problem is: Imagepath is a path, not an image variable
But: My knowledge of Xcode isn’t very good (yet), maybe there is a way to work around this

Hmm. But how would I get the path of the album art image?

I don’t know.

Perhaps you can save the artwork temporarily on disk

Darn, my app looks so nice too… :frowning:

http://www.flickr.com/photos/28119645@N00/415940725/

Have you tried this?

Thank you! Worked like a charm!

Er, moving to AppleScript Studio.

Hehe, you’ve never made apps using AppleScript before?

I have. This is AppleScript Studio code (as is the code I linked to):

Ah, you meant you’re going to move this topic to the AppleScript Studio forum. Haha, thought you meant you’re going to move on to AppleScript Studio, because this topic exemplifies how much it’s capable of… Don’t ask, please. :expressionless:

Haha, don’t worry about it. :slight_smile:

No offence masna but there are a lot of iTunes controllers out there. Is there any special features that yours has that doesn’t exist already? Take a look at mine, its got just about everything you need.
http://www.macupdate.com/info.php/id/22076

You need to work on your GUI as well…things are uneven and its just not that overly pleasing to the eye.

There were probably a lot of controllers before yours came out, and there will probably be more to come.