Search code examples
spotifylibspotify

Libspotfiy Playlist Folder handling


I'd like to get a few things cleared up about playlist folder handling in Libspotify. A few things seem a bit inconsistent about it (I get the impression folder handling has been hacked in as a bit of an afterthought?)

When I cycle through all the playlists in a container, I notice I get the same sp_playlist handle value for all the folders. This means I can't use any of sp_playlist_xxx functions on folders, right? So I can't register callbacks on them, cannot find out their name, etc?

Instead, I have to use special functions on the PlaylistContainer to get folder names?

Is it dangerous to use sp_playlist_add_ref and sp_playlist_release on handles pointing to folders?

Also, what is the sp_playlistcontainer_playlist_folder_id function intended for?


Solution

  • Your assumptions are mostly correct. Folder placeholders in the playlist container list are just that - placeholders.

    Instead, I have to use special functions on the PlaylistContainer to get folder names?

    Yes, sp_playlistcontainer_playlist_folder_name().

    Is it dangerous to use sp_playlist_add_ref and sp_playlist_release on handles pointing to folders?

    Not especially, as long as you don't over-release somewhere, but that's true of everything. You'll just have multiple owning references to the placeholder, which is fine.

    Also, what is the sp_playlistcontainer_playlist_folder_id function intended for?

    It's a unique ID for the folder, mainly there since you can't use the pointer as a unique identifier since all folders use the same placeholder object. It allows you to compare folders to one another without doing string comparison on the name (which, since multiple folders can have the same name, isn't actually a good idea).