Program 2: Java Music Playlist

Due Date and Submission Requirements


The goal of this lab is:


Background and Directions

In this program, you will use a circular doubly linked list to represent a music playlist. Your program will create a random playlist and allow a user to play songs, skip songs, and remove songs from the playlist. Because I dont wan't to deal with copyright issues with modern music, our playlist will only use CLASSICAL MUSIC (public domain!!)

There are twenty music files (.wav files) located in the music.zip. You will need to extract this folder, and then drag and drop the folder into your Java project (just like an input file). When the program starts, you will prompt the user for how big the playlist should be. A playlist will have N songs, where N is greater than or equal to 3 songs, but no more than 20 songs. You will then randomly select N songs from the folder of songs (no duplicates), and load each N songs into a circular doubly linked list as Node objects. You MUST use a circular linked list to represent the playlist, and you will need to keep track of the head and tail node. The zip file only has the audio files. The information for these files (titles and composers) are located in songs.txt, which you will also use in your program when creating Nodes.

Each song (Node) will have at least three values
Here is a diagram of how the circular linked list looks, where N = 6.


When the playlist is created, the program should print out the playlist from head to tail, and then display what the current song is (always start at the head). Then, the menu should appear. You need to implement the following menu funtionality: The menu should loop, and should be printed out each time it asks the user for the next action.

Getting your Java program to play music

Getting a java program to play sound is pretty easy-- we can just use some existing libraries. The AudioInputStream and Clip library can be used to play sounds. You will need to import both of these libraries in your code. Essentially, you will open up a sound file (.wav file) located in the music folder of your Java project with AudioInputStream, and then treat it as a Clip object. .start() will start playing the sound, and .stop() will stop the sound.

Assumptions

Playlist will be between 3 and 20 songs.

Hints

You are allowed to use an ArrayList. Your playlist must be a linked list still, but you may find an ArrayList to be helpful when you are creating the playlist with no duplicates.

Input file

Required Output

Your output and menu should look similar to the output seen in this video: https://youtu.be/oy6Z1L6GqIU.

Optional Hints

You might need to load all 20 nodes into a seperate data structure, then randomly pick N of those elements and place them into a linked list.
In your linked list, you may need to keep track of the current Clip object that is being played.
I'd recommend having our standard three class setup: a Node class, a LinkedList class, and a Demo class.

Grading (100 points)

W
Requirement Points
A random playlist of length N is created correctly 15
All N songs are loaded into a circular doubly linked list 15
The playlist is printed out, and the current song is printed out 10
A user can move to the next song, which will also stop playing any current sound 10
A user can move to the previous song, which will also stop playing any current sound 10
A user can remove the current song properly, and the linked list doesnt break 10
Node clas is correct 10
Program ends when all songs are removed from the playlist 5
Your program containts an adequate amount of comments 10

Acknowledgement

All music in this assignment fall under public domain. These audio files were gathered from Wikimedia Commons





Program 2 solution