The following chapter gives a short introduction on how to use the library to open the device and access tracks, playlist and disc usage statistics.

The IPod class

To access the contents of the ipod an instance of the IPod class needs to be instantiated with the mountpoint/drive letter of the device and opened with a call to the IPod::open() method.
For linux this would probably something like that
 IPod ipod( "/media/ipod" );
and
 IPod ipod( "E:" );
in a Windows environment.
See also:
IPodMountPoint::mountedIPods() returning a list of ipods connected to the system. The IPodMountPoint::getMountPoint() method returns the String to initialize the IPod class with.
Open the device with open()
 if( !ipod.open() ) {
     // failed
 }
After the IPod instance is opened the information stored on the device is accessible and can be retrieved.

Tracks and Playlists

Information about the tracks and playlists on the iPod device is stored in a database called ITunesDB and libqtpod contains the class ITunesDB representing this database.
The now opened IPod instance holds an instance of this class which is accessible thru the IPod::getITunesDB() method:
 // get the iTunesDB instance
 ITunesDB& itunesdb = ipod.getITunesDB();

Now we can iterate over the tracks stored on the device and print out artist, album, title and filename like this
 // get an Iterator over all tracks found on the device 
 ITunesDB::TrackConstIterator iter = itunesdb.getAllTracks();
 while( iter.hasNext() ) {
     // get the next track
     ITunesDBTrack * track = iter.next();
     // print track meta data
     printf( "%s\t%s\t%s\t%s\n",
         track->getArtist().ascii(),
         track->getAlbum().ascii(),
         track->getTitle().ascii(),
         itunesdb.getFileForPathInfo( track->getPathInfo() ).ascii() );
 }
See also:
ListTracksTest::run() in listtrackstest.cpp in the "tests" directory for another example on how to list the tracks sorted by artist

More examples can be found in the classes implementing Test in the "tests" directory.

Changes made to the database can be easily written back to the device by calling the IPod::synchronize() method:
 // synchronize with the device
 ipod.synchronize();

Device Statistics


Generated on Wed Nov 28 01:47:05 2007 for libqtpod by  doxygen 1.5.0