Search code examples
cocoalibspotify-2.0libspotify

How can I obtain the mosaic image for a playlist using CocoaLibSpotify?


From the header documentation of SPPlaylist for it's image property:

Returns the custom image for the playlist, or nil if the playlist hasn't loaded yet or it doesn't have a custom image

I have an array of loaded SPPlaylists however the image property on each object is always nil, even though I can see the 4-up image on those same playlists via the Spotify client.

Is there an easy way to obtain that 4-up cover image using CocoaLibSpotify? Or do I have to load all track and album metadata and pull back relevant SPImages individually?


Solution

  • The image of a playlist is for when branded playlists have custom images. This is fairly rare, though.

    The reason the grid isn't generated for you is because it's generated locally rather than server-side, so it'd mean loading multiple album's worth of images every time a playlist is loaded, which isn't that memory efficient.

    However, there's an open-source Spotify client called Viva built on CocoaLibSpotify (disclosure: written by me) that generates these images. Have a look at the VivaImageExtensions class extension for a reference implementation.

    It's worth nothing that the reference implementation there requires that the tracks you pass have had their album cover arts loaded first.