MCS2514 Fall 2013
Programming Assignment 2
“Music/Playlist Player”
++++++++++++++++++++++++++++++++++++++++++++
+ +
+ Please only submit MCS2514Pgm2.cpp, song.h and song.cpp +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
For this assignment you will be writing a simple music player with playlist capabilities.
You will need to be able to load in a “music library” (a song list) of songs on the
computer, and then allow the user to create a playlist of those songs to play. A playlist is
a list of songs that should be played. The order of the list determines the order in which
the songs should be played. One song file can be on a given playlist multiple times.
To implement this functionality you must first create a song class to extend the
mediaItem class that is included in the supplied source. The mediaItem class has the
ability to get and set the location of a .wav (audio) file and then play, pause, and stop
that file. Your new class should be a child class (derived class) of mediaItem that
extends its functionality to being able to store an artist name and song title with the song.
Make sure to implement your artist name and song title variables as private members of
the class with get( ) and set ( ) functions to manipulate them. Feel free to add any more
functions to your derived class that you see fit. Make it your own. You inherited it.
Next you should create an array or a vector of the new class you have created of length
MAX_SONGS.
You will need to read in a text file that describes all the songs we are using (as
described in the loadSongList function below) into this array. This will be your array
representing your music library. You will also need to make an array of integers to
store a playlist for the user. The playlist array should be an array of pointers (integers
which are the array index of songs) of length MAX_PLAYLIST. These pointers should
point to a song in your music library (a song list). This indirection will let you manipulate
the array pointers, while leaving your master music library array as a static structure.
Supplied for you is a GUI interface written in Visual C++. You should only need to
modify the file: MCS2514Pgm2.cpp as well as adding song.h and song.cpp files to the
project for the implementation of your class. You must implement the following functions
in MCS2514Pgm2.cpp to make the program work:
bool loadSongList(string filename)
INPUTS: a string containing a path to a file to open. This value is returned from
the user’s selection in the open file dialog.
OUTPUTS: a boolean indicating whether or not the file could be opened correctly.
This function should open a file containing a formatted list of song data. This data
should be in the following format:
An integer indicating the total number of songs
An Artist
A song Title
The file’s location on disk
(repeat these three the number of times indicated)
So for example:
2
Beastie Boys
Brass Monkey
./songs/Brass_Monkey.wav
Paul Simon
You Can Call Me Al
./songs/Call_Me_Al.wav
Note that each field is delimited by a newline character (n) there CAN BE
WHITESPACE in the fields! You should read all of this data into an array or a vector of
song objects you create as described above.
int getNumberOfSongsInSongList( )
INPUTS: NONE
OUTPUTS: An integer indicating the number of songs that are currently loaded
into your song object array or vector.
string getSongNameFromSongList(int songNum)
INPUTS: An integer indicating which song object (via its index in your song
object array or vector)
OUTPUTS: NONE
This function should return a string in the format of: “Artist – Song Title” that
corresponds to the specified song in your song list.
string getSongNameFromPlaylist(int playlistSpot)
INPUTS: An integer indicating which song to return (via its spot in the playlist)
OUTPUTS: NONE
This function should return a string in the format of: “Artist – Song Title” that
corresponds to the specified song in your playlist. Note that this is NOT the same
thing as getSongNameFromSongList. This function is returning the song data
that corresponds to the passed in spot in your playlist. Since the playlist is a list
of indexes in the array or vector, you will need to follow the index in the
designated spot to the actual song requested.
void addSongToPlaylist(int songNum)
INPUTS: An integer indicating which song from the song list to add to the playlist
OUTPUTS: NONE
You should add an index to the song from your song list indicated in the
argument, to your playlist array or vector.
int getNumberOfSongsInPlaylist()
INPUTS: NONE
OUTPUTS: Return an integer indicating the number of songs currently in the
playlist.
void removeSongFromPlaylist(int playlistSpot)
INPUTS: An integer corresponding to which spot in the playlist has a song that
needs to be removed
OUTPUTS: NONE
You should remove the song indicated from your playlist. Note: This does not
mean delete it from the song list/media library as well. Just the playlist. Again,
indirection.
void clearPlaylist()
INPUTS: NONE
OUTPUTS: NONE
You should reset the playlist to empty, i.e., it should be reset to contain no songs.
void moveSongUpInPlaylist(int playlistSpot)
INPUTS: An integer indicating which spot in the playlist has a song that needs to
be moved up.
OUTPUTS: NONE
You should swap the song indicated with the spot in the playlist above it (if there
is a song above it to swap with).
void moveSongDownInPlaylist(int playlistSpot)
INPUTS: An integer indicating which spot in the playlist has a song that needs to
be moved down.
OUTPUTS: NONE
You should swap the song indicated with the spot in the playlist below it (if there
is a song below it to swap with).
void playSongFromPlaylist(int playlistSpot)
INPUTS: An integer indicating which spot in the playlist has a song that needs to
be played.
OUTPUTS: NONE
You should call the playMedia() function that the song specified, inherited from
the mediaItem class.
void pauseSongFromPlaylist(int playlistSpot)
INPUTS: An integer indicating which spot in the playlist has a song that needs to
be paused.
OUTPUTS: NONE
You should call the pauseMedia() function that the song specified, inherited from
the mediaItem class.
void stopSongFromPlaylist(int playlistSpot)
INPUTS: An integer indicating which spot in the playlist has a song that needs to
be stopped.
OUTPUTS: NONE
You should call the stopMedia() function that the song specified, inherited from
the mediaItem class.
Please take note of the globals.h file. You will also notice the variable
SHOW_DEBUG_CONSOLE. It may be useful to see output from cout or any other
standard I/O function. If you set this variable to true, you will see a console started in
addition to the program GUI. You can output things here if you find it helpful.
When submitting your program you should only submit the following 3 files:
DO NOT SUBMIT THE SUPPLIED WINDOWS FILES.
1. MCS2514pgm2.cpp
2. song.h and song.cpp
REMMBER: DO NOT CHANGE OHTHER PROVIED FILES.
Example Screen from the program:
The post MCS2514 Programming Assignment 2 appeared first on My Assignment Online.