3 * Example program to list the playlists on a device.
5 * Copyright (C) 2005-2007 Linus Walleij <triad@df.lth.se>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 static void dump_plinfo(LIBMTP_mtpdevice_t *device, LIBMTP_playlist_t *pl)
29 printf("Playlist ID: %d\n", pl->playlist_id);
31 printf(" Name: %s\n", pl->name);
32 printf(" Parent ID: %d\n", pl->parent_id);
35 for (i = 0; i < pl->no_tracks; i++) {
36 LIBMTP_track_t *track;
38 track = LIBMTP_Get_Trackmetadata(device, pl->tracks[i]);
40 printf(" %u: %s - %s\n", pl->tracks[i], track->artist, track->title);
41 LIBMTP_destroy_track_t(track);
43 printf(" %u: INVALID TRACK REFERENCE!\n", pl->tracks[i]);
44 LIBMTP_Dump_Errorstack(device);
45 LIBMTP_Clear_Errorstack(device);
50 int main (int argc, char **argv)
52 LIBMTP_mtpdevice_t *device;
53 LIBMTP_playlist_t *playlists;
55 fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
58 device = LIBMTP_Get_First_Device();
60 printf("No devices.\n");
64 // Get playlist listing.
65 playlists = LIBMTP_Get_Playlist_List(device);
66 if (playlists == NULL) {
67 printf("No playlists.\n");
69 LIBMTP_playlist_t *pl, *tmp;
72 dump_plinfo(device, pl);
75 LIBMTP_destroy_playlist_t(tmp);
79 LIBMTP_Release_Device(device);