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