![]() |
![]() |
![]() |
libgpod Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
iPod database reading/writingiPod database reading/writing — Functions to read, write, and create an iPod database |
These functions are for reading, writing, creating, and deleting an iPod database and getting the total number of tracks and playlists.
Overview of using an iPod database:
itdb_parse()
: read the iTunesDB and ArtworkDB
itdb_write()
: write the iTunesDB and ArtworkDB
itdb_parse()
will return a Itdb_iTunesDB structure with GLists
containing all tracks the playlists in the database. Each track is
represented by an Itdb_Track. Each playlist is represented by an
Itdb_Playlist. See the Tracks
and Playlists sections for
details on tracks and playlists, respectively.
Each Itdb_Playlist has a GList called members
which contains all of
the tracks in the playlist. Tracks referenced in a playlist must also
be present in the tracks
GList of the Itdb_iTunesDB.
The iPod must contain one master playlist (MPL) containing all tracks accessible on the iPod through the Music->Tracks/Albums/Artists/etc. menu. In addition to the MPL there can be a number of normal playlists accessible through the Music->Playlists menu on the iPod. Tracks that are a member of one of these normal playlists must also be a member of the MPL.
The Podcasts playlist is just another playlist with some internal
flags set differently. Tracks in the Podcasts playlist are not
normally members of the MPL (so on the iPod they will only show up
under the Podcasts menu). All tracks referenced must be in the
tracks
GList of the Itdb_iTunesDB, however.
Each track may have a thumbnail associated with it. You can retrieve a
GdkPixmap of the thumbnail using itdb_artwork_get_pixbuf()
. A
thumbnail can be added with itdb_track_set_thumbnails()
. A thumbnail
can be removed with itdb_track_remove_thumbnails()
. Please see the
Artwork section for more
details on artwork related functions and structures.
Be aware that iTunes additionally stores the artwork as tags in the original music file. That's also from where the data is read when artwork is displayed in iTunes, and there can be more than one piece of artwork. libgpod does not store the artwork as tags in the original music file. As a consequence, if iTunes attempts to access the artwork, it will find none, and remove libgpod's artwork. Luckily, iTunes will only attempt to access the artwork if you select a track in iTunes. To work around this, gtkpod keeps a list of the original filename of all artwork and silently adds the thumbnails if they were 'lost'. Your application might want to do something similar, or you can supply patches for (optionally!) adding tags to the original music files.
The Itdb_iTunesDB, Itdb_Playlist and Itdb_Track structures each
have userdata
and usertype
fields that can be used by the
application to store additional application-specific data. If
userdata
is a pointer to an external structure, you can supply a
ItdbUserDataDuplicateFunc and a ItdbUserDataDestroyFunc so that this
data can be duplicated or freed automatically with a call to the
library _duplicate()
/_free()
functions.