Table of Contents

This is not a current assignment. If you are currently enrolled in SE1020, do not do this assignment expecting to receive credit for it.

Lab 6: Media Player Playlists

Objectives

* incorporate additional UI elements into a GUI application

Assignment

In this lab, you will extend your Media Player to incorporate the following functionality:

  1. Modify the Playlist UI so that music tracks can be added to and removed from the list.
  2. Add a the capability to save and load user specified playlists (collections of music tracks) to/from a file.

A word of advice: These two functional elements sound conceptually simple, but the implementation is rather involved. Get started EARLY, and ask plenty of questions. It is important for you to properly interpret and correctly implement the code shown in the UML diagrams below.

Detailed Requirements

- Download the MediaItem.java source file and add it to your project. Each instance of the MediaItem class represents a music track that can be played by the Media Player. As you can see from the UML class diagram below, one of the attributes of the MediaItem class is the fileName property that represents the audio file (.mp3, .wav, or .midi) containing the digitized music. Do not modify the MediaItem.java file for this assignment.

  1. Create a MediaController class which will be responsible (for now) for loading and saving different playlists. Each playlist is a collection of several MediaItems. The MediaController class must use either an ArrayList or a LinkedList to store a collection of MediaItems. Lab6 Class Diagram which includes MediaController
    1. The mediaItems attribute (declared as a List) should refer to an ArrayList or LinkedList object that contains the collection of MediaItem objects.
    2. The MediaController constructor should initialize the mediaItems collection so that it is initially empty.
    3. The add, remove, and save methods are used to implement the functionality for the Playlist Manager UI; that is, these methods are called by the Event Handler of the Playlist Manager UI.
    4. The load, pause, play, and stop methods are used to implement the functionality for the Media Player UI; that is, these methods are called by the button Event Handler or the Media Player UI. Only the load needs to be implemented for this assignment. Just leave the bodies of the other methods blank for now.
  2. Modify the MediaPlayerUI class as follows:
    1. Add a MediaController object reference as a field in the MediaPlayerUI class.
    2. Create a MediaController object and assign it to the newly added field in the MediaPlayerUIs constructor.
    3. Modify the constructor of the PlaylistManagerUI object so that it accepts a reference to the MediaController object created for the MediaPlayerUI object.
    4. The lab 6 “StartUp Sequence Diagram” clarifies these details. Lab6 Class Startup Sequence Diagram
    5. Separate the event handler class (MediaPlayerEventHandler) for the MediaPlayerUI, so that there are now two event handling classes namely MediaPlayerButtonEventHandler and MediaPlayerMenuEventHandler. As the names suggest, the MediaPlayerButtonEventHandler should be responsible for only handling the button events whereas the MediaPlayerMenuEventHandler class should handle all the menu events.
    6. The MediaPlayerButtonEventHandler should be modified such that the appropriate methods from the MediaController object are called.
  3. Modify the PlaylistManagerUI class to use a JList object as the UI component for the list of media items; follow these steps:
    1. Replace the JTextArea that currently displays the playlist contents with a JScrollPane object.
    2. Add a JList object within the JScrollPane.
    3. The constructor for the JList object needs to be passed a reference to a DefaultListModel.
    4. You may find the getSelectedIndex() and getModel() methods from the JList class useful.
    5. You may find these methods from the DefaultListModel class useful, as you'll find that you need to access the DefaultListModel contained by the JList to actually add and remove elements to and from the JList: addElement() and remove().
  4. Modify your existing PlaylistManagerUI class so that the Add button uses a JFileChooser dialog to allow the user to select a media file.
    1. The user must be able to select one or more files to be added to the playlist.
    2. If the user selects cancel, nothing is added to the play list and no error occurs.
    3. (Optional) Only files that end with the following extensions should be shown: .wav .mp3 and .midi. Add Media Item JFileChooser
  5. Modify your existing PlaylistManagerUI class so that the Cancel button reverses the changes made to the playlist. This can be accomplished by removing all of the items in the DefaultListModel of the JList and then repopulating it with the filenames found in the MediaController object. The sequence diagram provided below clarifies the details. Lab6 Sequence Diagram for "Cancel"
  6. Modify your existing PlaylistManagerUI class so that the Save button uses a JFileChooser dialog to allow the user to save the playlist to a file using an ObjectOutputStream object. Please note that you would have to make your MediaController class Serializable to accomplish this. Instead of making the MediaController class Serializable, it is recommened that you instead just serialize the ArrayList or LinkedList collection within MediaController. Note: The event handling for the Save button must first update the mediaItems in the MediaController object with the list of file names found in the JList. A sequence diagram has also been provided (below).Save Playlist JFileChooser Lab6 Sequence Diagram for "Save"
  7. Modify your existing PlaylistManagerUI class so that the Remove button removes the currently selected media item from the playlist. If no item is selected, the button should do nothing. Remove item from Playlist
  8. Modify your existing MediaPlayerUI class so that the Open Playlist button uses a JFileChooser dialog to allow the user to open a previously saved playlist using an ObjectInputStream object Open Playlist JFileChooser

Report

This is a one week assignment. Submit your assignment, including a lab report, according to your instructor's directions.

FAST Data

You should indicate how much time (in minutes) you spend on this assignment in the FAST database. You are encouraged to log your activity as you work on the project. At a minimum, you should log all of the time spent on this assignment before the due date given above. All time spent on this assignment should be entered into the week 7 column (even if you worked on it in week 8).