Project 4 - myTunes

Due Friday 4/24 - 5PM

The goals of this project are as follows:
  • gain experience with program design
  • gain experience using recursion
  • gain experience using JList, JMenuBar, JMenu, and JMenuItem
  • practice using additional third-party libraries
  • practice file i/o and text parsing
  • practice algorithmic thinking
For this project, you will design an iTunes-like program that plays MP3s.  The GUI of your program will look similar to the following:


You program must provide, at minimum, the following functionality:
  1. Import MP3s - Use the JFileChooser to allow the user to select a directory.  Recursively traverse the directory and all of its descendants and display the list of MP3s found in a JList.
  2. Open Library - Use the JFileChooser to allow the user to select a file containing a myTunes library previously saved using "Export Library".  Open the file and display the library contents in a JList.
  3. Export Library - Use the JFileChooser to allow the user to specify the name of a file where the current MP3 list should be saved.  Save the contents to the file.
  4. Play - Begin playback.  First, play the song that is currently selected.  When playback of that song completes, continue down the list until the user clicks Stop.
  5. Stop - Stop playback.  If no song is playing, do nothing.
  6. Next - If a song is currently playing, stop playback of that song and skip to the next song in the list.  If no song is playing, do nothing.
  7. Shuffle - Randomize the list of songs.  If a song is currently playing, stop playback.  

Extra Credit Options

  1. Add - Provide a menu option that will allow a user to add songs to an existing library.
  2. Previous - Allow the user to go back to the previous song.
  3. Podcasts - Allow the user to download and listen to podcasts.
  4. Merge Libraries - Allow the user to merge two existing libraries.
  5. Extra credit will not be awarded for the following operations you will be implementing for Project 5:
    1. Sort songs by artist/title.
    2. Search songs for a given artist, title.
    3. Support for playlists.

Implementation Details

  1. You will need to design the format you will use to store the library data.  iTunes uses XML for this purpose, but you may store the information in plain text format.  (Programs using XML will receive extra credit.)  It is recommended that you store the artist, title, album, and name of the file where the MP3 is stored.
  2. To shuffle, you will need to randomize the order of the list of songs.  It is recommended that you use java.util.Random.  A standard algorithm for randomization is, for each item, extract it from the list and insert it into a random position.
  3. Use jAudiotagger to read the ID3 tags of the MP3 files.  This will allow you to extract the artist, album, and title of the song during Import.
  4. Use JLayer for playback.  You can create a Player object from an InputStream and invoke the play method to begin playback.  The close method stops playback.
  5. When invoking the play method to play a song, the method will not return until the song is finished playing.  In order for your program to respond to other events during playback, you will need to create a new Thread that invokes the play method.  A basic example of this is as follows (though, you may do more inside of your run method):

player = new Player(is);

Thread t = new Thread() {

    public void run() {

        try {

            player.play();

        } catch(Exception e) {

            e.printStackTrace();

        }

    }

};         

t.start();


Comments