getting artwork from Catalina's Music app via ScriptingBridge

for years we've been able to get the artwork of the song currently playing in iTunes via the ScriptingBridge.


porting iTunes ScriptingBridge code to Catalina has been fairly painless, and works fine for getting basic information like currently playing artist, title, album, etc.


however, we found that the Catalina Music app will only report its cover art over the scripting bridge in some cases. as you know, there are basically two cases where cover art might come from. 1.) it might be embedded in the played MP3 file directly 2.) the music app might have downloaded the cover art

in both cases, the music app itself will display the cover art just fine. prior to 'Catalina' we were also able to get the cover art from iTunes in both cases without problem. however, the 'Catalina' music app doesn't let other apps access the cover art over the scripting bridge in case 2.) anymore. just in case 1.)


we are currently using this code, but are just running into the error case. does anyone have better success here?


MusicApplication *musicApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.Music"];

SBElementArray *artworks = musicApp.currentTrack.artworks;

if ([artworks count])

{

MusicArtwork *ma = artworks[0]; // using [ get] doesn't change a thing

NSImage *image = ma.data;

NSData *rawData = ma.rawData;

if ([image isKindOfClass:[NSImage class]])

self.coverView.image = image;

else if ([rawData isKindOfClass:[NSData class]])

self.coverView.image = [[NSImage alloc] initWithData:rawData];

else

{

self.coverView.image = nil;

NSLog(@"Warning: unknown artwork class %@", ma.description);

}

}


full sample code to test out the problem is here:


https://www.dropbox.com/s/f7ljtzz0lq93j3f/_bugMusicAppArtworkTest.zip?dl=1

Replies

> Please note: your content was added successfully, but a moderator needs to approve it before it can be posted.



for 5 days now? huh?

I'm experiencing this issue too. The data property is nil, and the rawData property remains an SBObject, instead of NSData as it used to with iTunesApplication.


(lldb) po artwork.rawData
<SBObject @0x600000ca5bf0: rawData of <class 'cArt'> 0 of <class 'cShT'> id 169358 of <class 'cUsP'> id 77205 of <class 'cSrc'> id 63 of application "Music" (9374)>

still the same experience here on catalina 10.15.2 Beta (19C32e), any update or workaround for this?

  • Add to Phrasebook
    • No word lists for English (USA) -> Hungarian...
    • Create a new word list...
  • Copy

ok, one workaround for this https://github.com/w0lfschild/iTunesPlus/blob/master/iTunesPlus/iTunesPlus.m


works from catalina 10.15.2 beta2 (and still ok with beta3)