Afternoon,
I’m writing a small applescript app in xcode to help manage my music collection. I’m trying to display the artwork from the tracks. I use the following code to get the artwork data from iTunes:
tell application “iTunes”
set track_x to track 17 of playlist “Library”
set artwork_data to data of artwork 1 of track_x
end tell
It returns the data as an NSAppleEventDescriptor. I query to get the class using:
current application’s NSLog(“%@”, class of artwork_data)
Result:
<NSAppleEventDescriptor: ‘JPEG’>
I have tried all kinds of ways to try and extract the data to create an NSImage but I can’t figure it out. I’ve looked at examples for extracting data from NSAppleEventDescriptors that a contain lists etc. I also tried the following, with no luck
set theCode to current application’s NSHFSTypeCodeFromFileType(“rdat’”)
set theData to (current application’s NSAppleEventDescriptor’s descriptorWithDescriptorType:theCode |data|:theData) as data
Any thoughts?
Cheers,
James.