You are not logged in.
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.
Offline
Just get its data:
Applescript:
set theData to theDesc's |data|()
set theImage to current application's NSImage's alloc()'s initWithData:theData
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline
Shane,
Thank you for the quick reply. I have tried implementing your suggestion, and get the following error:
doesn’t understand the “data” message. (error -1708)
Any thoughts?
James.
Offline
Try changing it to:
Applescript:
set theData to (current application's NSArray's arrayWithObject:theDesc)'s firstObject()'s |data|()
Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com
Offline
Shane,
That did the trick! Thank you for everything you do for the community!
Cheers,
James.
Offline