Skip navigation.
 
mlRe: Setting iTunes album art with ScriptingBridge
FROM : Dave Verwer
DATE : Thu Feb 28 21:28:51 2008

Thanks for the reply, I eventually solved this by resorting back to
AppleScript for the artwork stuff, ugly but it works...

As for posting source to the list, thanks for the tip. Some lists
frown upon it so I have been using Pastie but I will paste small code
samples inline from now on.

Cheers
Dave


On 2/27/08, Bill Monk <<email_removed>> wrote:
> On Feb 27, 2008, Dave Verwe wrote:
>
>  > // Add to iTunes
>  > iTunesApplication *iTunes = [SBApplication
>  > applicationWithBundleIdentifier: @"com.apple.iTunes"];
>  > iTunesTrack *track = [iTunes add: [NSArray arrayWithObject: [NSURL
>  > fileURLWithPath: file]] to: nil];
>  >
>  > // Convert to PICT
>  > NSData *tiffData = [artwork TIFFRepresentation];
>  > NSPasteboard *pboard = [NSPasteboard pasteboardWithName:@"Sample"];
>  > [pboard declareTypes: [NSArray arrayWithObject: NSTIFFPboardType]
>  > owner: nil];
>  > [pboard setData: tiffData forType: NSTIFFPboardType];
>  > [pboard types];
>  > NSData *pictData = [pboard dataForType: NSPICTPboardType];
>  > [pboard releaseGlobally];
>  >
>  > // Add the artwork to the track
>  > iTunesArtwork *artwork = (iTunesArtwork *)[[SBObject alloc]
>  > initWithProperties: [NSDictionary dictionaryWithObjectsAndKeys:
>  > @"data", pictData, nil]];
>  > [[track artworks] insertObject: artwork atIndex: 0];
>
>  I haven't delved deeply into Scripting Bridge, but based on something
>  similar that occurs when Applescripting iTunes, I suspect the problem
>  is in the line:
>
>  > [[track artworks] insertObject: artwork atIndex: 0];
>
>  A track's "artworks" does not exist for tracks which do not already
>  contain artwork. Further, if you try to access it (or "kind of front
>  artwork"), certain versions of iTunes will return the classic "Apple
>  event not handled" error -1708. Other versions will return 0, as one
>  might expect.
>
>  In any case, your solution in SB likely involves avoiding "artworks"
>  altogether. Basically you want to replicate the Applescript command
>
>  set data of front artwork of someTrackReference to somePICTData
>
>  Observe that "artworks" is not involved at all. It will only exist
>  for the track after some artwork data has been added.
>
>
>  (PS. I think it's preferable to include small code snippets in list
>  postings rather as links to some external "snippets" web page. For
>  one thing, that page may not exist years from now. For another,
>  people who could possibly help with your issue may not bother to
>  click your link. I almost didn't.)
>



--
e-mail: dave.<email_removed>
web: http://shinydevelopment.com

Shiny Development Ltd. is registered in England, Registration Number:
05805802. Registered Office: 4 Claridge Court, Lower Kings Road,
Berkhamsted, Herts., HP4 2AF.

Related mailsAuthorDate
mlSetting iTunes album art with ScriptingBridge Dave Verwer Feb 27, 14:55
mlRe: Setting iTunes album art with ScriptingBridge Bill Monk Feb 27, 20:20
mlRe: Setting iTunes album art with ScriptingBridge Dave Verwer Feb 28, 21:28
mlRe: Setting iTunes album art with ScriptingBridge Daniel Thorpe May 22, 18:58
mlRe: Setting iTunes album art with ScriptingBridge Kyle Sluder May 23, 04:53
mlRe: Setting iTunes album art with ScriptingBridge Jens Alfke May 23, 17:06
mlRe: Setting iTunes album art with ScriptingBridge Bill Monk May 23, 22:08