album art won't update [iTunes; image view]

Hi Hendo,

I use the awake from nib handler anyway to setup some things,
so I “hard-coded” my image view

set imageView to a reference to image view "artwork" of window "main"

So this:

set imageView to a reference to image view "artwork" of window "main"

went in to your awake from nib handler?

Exactly, but my image view is directly on the top level of the main window

right, so I just have to reference properly…shouldn’t be a problem, thanks;)

hmm, that didn’t work, I’m getting an NSInternalScriptError - should I uncheck awake from nib in my image view?

Yes, I have nothing checked, only the name is defined

works perfectly now, thanks! :smiley:

how would i make the ArtworkController.m file work for a remote computer that is defined in a variable.

bump

There’s no such things as monsters :lol:

huh?

things that go “bump” in the night (hence monsters;))

ok…well does anyone have an answer to my question?

Hi all,

I’m having similar issues myself. I’ve read the thread and have seen the OBJ-C code that reportedly worked, but I wanted to know if there was a pure Applescript way to obtain the artwork from iTunes and display in an image view, on the fly, without saving to disk first.

The code that I am using is:


(* code to get the artwork *)
tell application "iTunes"
try
set theImage to data of artwork 1 of current track (* this should store it in that variable *)
on error
display dialog "Error in getting artwork" (* this only seems to happen when artwork is non-existent *)
end try
end tell

(* code to set image artwork in my app window *)
tell window "myRemote"
try
set image of image view "artwork" to theImage
on error
display dialog "Setting image failed" (* this happens every time *)
end try
end tell

Does anyone see where I could be going wrong? :confused:

i believe its because data of artwork 1 returns a bunch of garbled numbers and letters. There is no reason why you wouldn’t use the Obj-C jobu provided. IT’s far better than writing to temporary files.

rustinpeace…
After much discussion and experimentation with this topic, it seems like most other people are willing to trust that there’s no other way to do this than by using code similar to what I posted. Applescript alone simply doesn’t have the object support necessary to achieve this… otherwise we wouldn’t have had to use this workaround, eh?

Of course, dude. I’m sure lots of people here do… including me. The point of us not responding is that you seem to expect us to hand it to you every time and I just don’t have the time to do that. For the most part, I’ve already given you the answer. If you used your gray matter a bit, you’d probably be able to hack it together… or at least get things started. And, quite frankly, I’ve been too lazy to turn on my other computer and work out the code just for you. If it will stop you from bumping this post, here’s the solution…

property remoteMachine : "eppc://username:password@some-guys-powerbook-g4-15.local"

to updateData()
	using terms from application "iTunes"
		tell application "iTunes" of machine remoteMachine
			if exists (database ID of current track) then
				set cur_song to the name of the current track
				set cur_artist to the artist of the current track
				set cur_album to the album of the current track
				
				if (count artwork of current track) > 0 then
					-- set cur_art to data of artwork 1 of the current track as picture --> NOTE THIS CHANGE!!!
					set cur_art to artwork 1 of the current track --> Changed to this
				else
					set cur_art to missing value
				end if
			else
				set cur_song to "No Song Currently Playing"
				set cur_artist to "N/A"
				set cur_album to "N/A"
				set cur_art to missing value
			end if
		end tell
	end using terms from
	--> Do some stuff with the name, track, etc...
	call method "displayArtworkInImageView:trackHasArtwork:ofEPPCMachine:" of class "ArtworkController" with parameters {imageView, (cur_art is not missing value), remoteMachine}
end updateData

It may be important to note the line above (marked by “NOTE THIS CHANGE!!!”) which I changed. Because you’re fetching the image data over the network, it may be slow enough in getting the data to hang your app. Rather than getting the data up front, you should just test to see if there’s any artwork there and then only fetch the actual data once in the obj-c method.

Add this method to your ArtworkController subclass…

j

thanks. i’m sorry if it seems like i’m not thankful for all the help you’ve given, because i am.

i’m having the same problem that hendo had on the first page i get this error: flyTunes has exited with status 0.
i couldnt solve my problem but looking at you wrote. if anyone can help i can send you the source to the project. thanks.

anyone?

Hi Hendo,

I’ve also used jobu’s Obj-C method in my program (iTunes Art Switcheroo - posted in scriptbuilders) without any problem with updating. Of course, this is in the main window where I have my image view set up.

Question: You said jobu’s method worked before you decided to move things inside tab view. Have you ever successfully loaded an image in this new setting or not?

If you have successfully displayed an artwork in your tab view, then the problem must be in coding (rather than environment) to purge the old image and then replace it with the new art. Just wondering what’s causing the problem.

archseed :slight_smile: