MAFW Manual |
---|
You need to get the number playlist elements and then query
for each one to know its object_id
:
{ size = mafw_playlist_get_size (playlist, &error); if (error != NULL) { /* Error management */ } for (i = 0; i < size; i++) { gchar *oid = mafw_playlist_get_item (playlist, i, &error); if (error != NULL) { /* Error management */ } /* Information treatment */ } }
If you want more information, like metadata associated to a
particular object_id
you have to use the asynchronous
API.
As in the last example, first you need to know the playlist size and then query metadata for a range within the playlist limits. Usual use case could be from the beginning to the end of the playlist:
{ size = mafw_playlist_get_size (playlist, &error); if (error != NULL) { /* Error management */ } mafw_playlist_get_items_md (playlist, 0, size - 1, MAFW_SOURCE_LIST (MAFW_METADATA_KEY_TITLE), playlist_get_items_md_cb, NULL, NULL); } static void playlist_get_items_md_cb(MafwPlaylist *playlist, guint index, const gchar *object_id, GHashTable *metadata, gpointer userdata) { GError* error = NULL; GValue* value; const gchar* title; value = mafw_metadata_first (metadata, MAFW_METADATA_KEY_TITLE); title = g_value_get_string (value); /* Probably show this title string in the UI */ }
You can see the metadata is returned in a hash table that can contain metadata with multiple values and this is why MAFW provides mafw_metadata_first to access the first (or only) element in the hash table for a particular metadata key. If you want to get more values you could access directly the hash table. If there is only one value, the hash table will return a GValue, but if it is multi-valued, it will return a GValueArray. Take a look at the Mafw API reference for more info.