Reusing id3lib

Each MP3 file contains meta-data called "ID3 tags" that can be accessed and manipulated through low-level file operations, or via a higher-level interface. We saw two interfaces for using the library in Section 16.3. For this exercise, we have provided you with classes from three libraries (http://oop.mcs.suffolk.edu/dist) and you are to write a program that reuses them all.

ID3 tags enable you to read and store meta-information about MP3 songs in a special part of the MP3 file itself. To manipulate MP3 files as though they were C++ objects, getting and setting properties that persist in the ID3 tags, we reuse an ID3 library. You will be provided with a FileTagger class that depends on id3lib, but implements the Mp3Song interface.

Check out some of the executables that come with id3lib: id3info, id3convert, id3tag, id3cp. They all have man pages.

The Assignment

1.

Install id3lib.

2.

Build filetagger.cpp with TestFileTagger.cpp and run it on a folder with some junk MP3 files that you do not care about. Verify that the test case passes.

3.

Enhance the playgen program so that its output playlist includes ID3 tag information in the playlist.

playgen [directory] playgen [file1.mp3] [file2.mp3] ...

playgen generates a playlist of all MP3 files in the directory, or of all MP3 files supplied on the list of command line arguments. It should read the id3tag information from each file it visits and display each song in the format shown in Example 25.4.

Example 25.4. filetagger-examplefiles/test-winamp-playlist.m3u

#EXTM3U #EXTINF:134,Tom Lehrer - Vatican Rag Tom LehrerYearThatWas14_Vatican Rag_Tom Lehrer.mp3 #EXTINF:131,Tom Lehrer - Folk Song Army Tom LehrerYearThatWas4_Folk Song Army_Tom Lehrer.mp3 #EXTINF:155,Tom Lehrer - National Brotherhood Week Tom LehrerYearThatWas1_National Brotherhood Week_Tom Lehrer.mp3

It is suggested you use ArgumentList to process command line options, and FileVisitor to visit each file.

Категории

© amp.flylib.com,