Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this project you will create a simple, command line-based program to view and play songs in a collection of MP3 files. You must complete

In this project you will create a simple, command line-based program to view and play songs in a collection of MP3 files. You must complete a partial implementation of the SimpleArrayList class (already done), and implement the MP3File and MyMP3Files classes. MyMP3Files must contain the main method for your project. Your program must rely on provided class library to play MP3 files and access the embedded tags in the files, such as the title, author, album, and date. A Java class for playing MP3 files along with the necessary jar files will be provided to you. 1. Create a class MP3File , which should implements the following constructors and methods : MP3File() MP3File(String pathname) String get Path () void setPath(String pathname) String getAuthor() void setAuthor(String author) String getAlbum()

void setAlbum(String album) String getDate() void setDate(String date) String getTitle() void setTitle(String title) String toString() boolean equals() void play() This class should represent information about a single MP3 file on disk. The constructor should access the suitable values of the ID3tags embedded in the file (as listed in method names). An example program is shown below The toString method should return a String with the author, title, album, and date. The play() method should play the MP3 file .

Examine the example programs PrintMP3Properties.java and TestMP3Player.java Create the MP3File class and provide the fields (instance variables) for the necessary attributes, including the pathname of the MP3 file (it should be its absolute pathname!), as well as the author, album, date, and title of embedded as ID3 tags in the MP3 file. In essence, an MP3File class object represents the information about a single MP3 file on disk. It can also play the MP3 file, if needed (using the method play()). The constructor should simply access an MP3 file (as in the PrintMP3Properties) and initialize the instance variables to the retrieved ID3 tags. It should set the path to the MP3 file, as well. A default constructor should just create an empty object instance. Implement the required getters/setters. place the MP3Player class in the same package. You will need it to implement the play method. It should be implemented very similarly to the main method in the TestMP3Player.java example. Note that the (absolute) path of the file to be played is available as one of the instance variables of the MP3File class. The getPath() method should return it.

2. Create a public class MyMP3Files in the default package, which should:

Prompt the user for a directory name; you may assume that the directory contains only MP3 files.

Read the file names from the given directory and create a SimpleArrayList of MP3File objects , one for each MP3 file in the directory (you should check if the file has the .mp3 suffix) The files in the list should be in the same order as the files in the directory.

Create an iterator for your list of MP3 files

Iterate over all files and print the information about each file (using toString).

Iterate over all files again, starting from the beginning. This time, for each file in the list, print the file information (using toString) and then pause, waiting for a user command Subsequently, if the user enters:

n ,move to the next file, if present; otherwise print end of the list;

b, move to the previous file, if present; otherwise print top of the list;

i, print the information about the current file, including its path;

p, play the current file;

h, print a short help information about these commands ;

q, quit the program.

All input should be from System. in and output (except for playing MP3 files) to System.out

The classs main method should accept a path from the user. You may also accept the directory from the command line (using args[0] in the main method). If not provided on the command line, you would prompt the user for the directory name. The path should be a directory name containing a collection of MP3 files. Declare a SimpleArrayList variable and initialize it. The list (a generic class) should be instantiated to hold MP3File objects. At first, the list will be empty, but it will be used to hold MP3File objects, one for each file in the directory. Use the File class to access the directory (provided by the user on the command line or given by the user). First, use suitable method in the File class to check if the path is in fact a directory and then use a suitable method (e.g., listFiles()) to get the list of all files in the directory. Then, iterate through the list of files in the array. For each file, check if its path has the .mp3 suffix and if so, create an MP3File object instance for this file and append it to the SimpleArrayList. If the path does not end with .mp3, you can simply ignore the file. Finally, the SimpleArrayList object you created should contain one MP3File object instance per each MP3 file in the directory. Also, each of these objects should have the absolute path of the corresponding file, and the ID3 tags retrieved from the file. The MP3File objects will be in the same order as they are listed in the File[] array returned by listFiles() and not necessarily in any alphabetical order, which is fine. Create an iterator object for your SimpleArrayList by calling the listIterator() method. (You must not call the constructor for the SimpleArrayListIterator directly -- read the IMPORTANT note above.) Using the iterator, iterate over all files and print the information about each file (using toString). Create another iterator and start a loop for processing the user commands To implement the commands n and b, use the iterators hasNext(), hasPrevious(), next(), and previous() methods. For the command p, use the MP3Files play() method to play the current file. At any time, you should have the current file while iterating through the files on the list. This is the object instance (current file) on which you should call the play method, if requested by the user. You should have a variable MP3File referring to the current file, which should be updated each time you call next or previous.

https://drive.google.com/open?id=1IcCpvNUXI5SXfBv-FWwJYpD3RIvIM4OH

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

Simplify by using the imaginary unit i. -8. -8

Answered: 1 week ago