This assignment introduces the second part of the MP3 player project that we’ll complete this semester. Following on from the first assignment, we now start handling real MP3 files and extracting information about the track from them. We also modify the TrackList class to hold Track objects and support sorting of tracks and searching for tracks by title. Finally we will read and write track lists as M3U format files. These are commonly used to exchange track lists between desktop MP3 players.
As before, this document sets out the main requirements for the assignment but more detail is given in some of the unit tests that you are supplied with. For this assignment you will be given most of the required tests, but you will be asked to write some tests yourself. You will be assesed based on your code passing our tests and on the quality of your code, tests and documentation.
The work for this assignment is split into three parts: implmenting and testing the Track class, implementing search and sort methods on the TrackList class, and reading and writing files. The last of these is intended as an extension for students looking for higher grades.
All queries to Steve.Cassidy@mq.edu.au or via the Assignment Discussion Forum on iLearn. See image.
The first modification to the earlier project is to build an explicit representation of a track which can hold more information about an MP3 file. We do this with a Track class which represents an mp3 file on the file system; we can then use instances of Track to manipulate mp3 files; in our case, we will use it to extract various properties of the file, such as the artist, track name and album title.
To extract information from the MP3 file we will use a third party library that can read the ID3 format tags stored in most MP3 files. Instructions on how to install and use the jid3lib library from http:// javamusictag.sourceforge.net/ will be given later.
The Track class provides the following interface:
No tests are provided for the Track class. Part of your task is to write suitable tests for the above methods.
The TrackList class is similar to the one that you implemented in assignment 1 except that it stores an array of Track instances rather than an array of Strings.
You are provided with a modified version of the assignment 1 solution which implements all of the methods you wrote for TrackList but using Tracks instead of Strings. The only difference in this implementation is that no TrackListFull exception is thrown by the append method. Instead, if there is no room for the track being added, the grow method is called to make more space. The tests have also been modified and the code you are given passes all of the relevant tests. One method, contains has been removed as it is replaced with a different search method below.
Your task is to extend the TrackList class with a number of new methods relevant to handling lists of MP3 Tracks. These relate to sorting and searching the list, and reading and writing tracklist M3U files. The new methods are split into two groups: one is core and should be completed by everyone, the other is an extension and should be completed by those aiming for a higher grade.
The core set of methods relate to searching and sorting track lists:
The extension set of methods relate to reading and writing lists of tracks and generating track lists from a directory of MP3 files.
An M3U file is a very simple file format used to exchange lists of tracks for MP3 players. You may have come accross them if you’ve used desktop players such as Winamp. M3U files are very simple: each line is the name of an MP3 file which can be either:
In addition, any line beginning with the # character is ignored as a comment. Blank lines are allowed in the file and are ignored. For this assignment, we will only work with M3U files containing relative local path names. So an example M3U playlist would be: See image.
If this file were stored in the directory C:\Music then you would expect to find the first track in C:\Music\ Blues\Kevin_MacLeod_-_01_-_Niles_Blues.mp3.
MP3 files can contain tags with information about the track such as artist, title, album and track number. To read these tags you need to look inside the MP3 file and understand its format. This is a complex task and so we will take advantage of someone elses work and use a library to get access to tag information.
The Java ID3 Tag Library is an open source project http://javamusictag.sourceforge.net/ that provides a library to access ID3 tags in MP3 files. The full documentation and some useful examples can be found on the website. You need to download the file jid3lib-0.5.4.jar. (A Jar file is a Java library archive, it contains all of the compiled class definitions for that libary). Download this file and copy it to somewhere in your file space - that is, don’t leave it in a temporary directory.
To make use of the library in your Eclipse project you need to add this JAR file to the build path. Here is the procedure:
You can read the full documentation and examples on the website but the main things you will need from this library are as follows:
Included in the zip file starter pack are a number of sample MP3 files. These were downloaded from http://freemusicarchive.org/ which provides music that can be redistributed with attribution (which is provided in the TrackListTest.java comments). The tracks are stored in the music directory. One MP3 file is provided that has no ID3 tag information - Theme - Fat Albert.mp3, this is taken from the test data that comes with the JID3Lib distribution. The remaining tracks in the Test directory all contain usable ID3 tags and can be used for testing searching and sorting.
You are provided with a set of JUnit tests for the TrackList class which test the provided methods and those you are asked to write above. Part of the mark for this assignment will be based on your code passing these tests. You are also required to write tests for the Track class. In grading your assignment, we will run our own set of tests against your implementation. Your tests will be checked manually for quality and completeness.
Your final task, once you have passed all of the tests that are provided, is to write a simple application that makes use of the TrackList class. This means that you need to define a public static void main(String[] args) method either in the TrackList class or in a new class that you define. Your application should:
Clearly, this requires that you have completed the extension parts of the TrackList class. If you only complete the core methods, you won’t be able to do this part of the assignment.