-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer_V1.cpp
243 lines (206 loc) · 7.55 KB
/
Player_V1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/**************************************************************
* Name of the file: Song.cpp *
* Group 6: Ra'Caria Burgess, Janei Elliston, *
* Michael Mondelice, Michael Parrish *
* Date last edited: 4/24/2020 *
* Purpose of Player.cpp: allow users to create new named 8
* playlist, view all the playlists, merge (intersect) *
* exisiting playlists into a new list, and play a playlist. *
**************************************************************/
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cmath>
#include <string>
#include "Playlist.h"
#include "StringHelper.h"
#include "Song.h"
int count;
void createNewList(vector<Playlist>&lists){ //accepts a vector as arguement and creates a new playlist.
lists.push_back(list);
count++;
string name;
cout <<"Enter Name for Playlist: ";
cin >> name;
lists[count].setName(name);
}
using namespace std;
void parse(vector<string>&temp,string songLine){
string word = "";
for (int x=0;x<songLine.length();x++)
{
if (songLine[x] == ',')
{
temp.push_back(word);
// cout << word << endl;
word = "";
}
else
{
word = word + songLine[x];
}
}
temp.push_back(word);
}
void PlaylistMenu(vector<Playlist>&list){
int choice3;
do{
cout << "1 - Create new empty list" << endl
<< "2 - Merge 2 existing playlists" << endl
<< "3 - Intersect 2 existing playlists" << endl
<< "Selection: ";
cin >> choice3;
if (choice3==1){
createNewList(list); // creates a new playlist
SongMenu(count); // opens song menu afterwards so that songs can be added to list.
}
else if (choice3==2){
// merge 2 playlist function (need)
// cout << "Which of the following playlists would you like to merge" << endl;
// How do you print out playlist ?
//
}
else if (choice3==3){
// intersect 2 playlist function (need)
}
else if (choice3!=4){
cout << "Invalid Entry. Please input a valid entry." << endl;
}
}while(choice3!=4);
}
void SongMenu(int location){ // menu takes integer argument so that the specific playlist vector can be referenced by functions in this menu (example: mp3[location].addSong())
Playlist List;
Song S;
string title, artist, album, year, len; // IS THIS NEEDED ??
char m;
int choice3;
do{
cout<<"You are now playing: " /*cout playlist name (need)*/ << endl
<<"1 - Add a song"<<endl
<<"2 - Delete a song"<<endl
<<"3 - Play a song"<<endl
<<"4 - Set the mode"<<endl
<<"5 - Show all songs"<<endl
<<"6 - Quit"<<endl<<endl
<<"Selection: ";
cin>>choice3;
if (choice3==1){
// RUN ADD SONG (need)
// cout << "Song Details\n";
// cout << "Title: ";
// cin >> title;
// cout << "Artist: ";
// cin >> artist;
// cout << "Album: ";
// cin >> album;
// cout << "Year: ";
// cin >> year;
// cout << "Length (in seconds): ";
//cin >> len;
//
// IDK HOW TO READ INFO BACK INTO FILE
// S >> S.title >> S.artist >> S.album >> S.year >> S.length;
// STILL TRYING TO FIGURE OUT THE OVERLOAD OPERATOR
// List = List + S;
}
else if (choice3==2){
//run delete song function (need)
// cout << "Enter to delete: ";
// cout << "Title: ";
// cin >> title;
// cout << "Artist: ";
// cin >> artist;
// HOW TO READ INTO SONG
// IDK WHAT TO USE IDK HOW TO USE OVERLOAD
// List.deleteSong(S);
// List = List - S;
// cout << "Song successfully deleted" << endl;
}
else if (choice3==3){
//run play song function (need)
List.play();
}
else if (choice3==4){
//run set mode function (depending on how function is written a menu may need to be created as well) //run play song function (need)
cout << "Enter Mode: \n";
cout << "N - Normal\n";
cout << "R - Repeat\n";
cout << "L - Loop" << endl;
cin >> m;
// List.setMode(m);
}
else if (choice3==5){
//run print function for all songs in playlist (need)
// cout << List;
}
else if (choice3==6){
//exit song menu back to main menu this if will be blank to prevent the else from printing Invalid Choice message (need)
}
else{
cout<<"Invalid Choice" << endl << endl;
}
}while(choice3!=6);
}
int main(){
//open playlist file and store data in vectors, create a count for the vector as well (need)
ifstream inF,inF2;
int choice1, choice2;
vector<Playlist> mp3;
string word, songLine;
bool choice2_flag=false;
inF.open("Playlist.list");
while(!inF.eof()){
inF>>word;
//initilize temp playlist object to push into the vector of playlist objects
Playlist tempPlistObj;
// set and display temp playlist object name from file
tempPlistObj.setName(word);
cout<<word<<endl;
word+=".playlist";
inF2.open(word.c_str());
//created while loop to store the songs for each temp playlist object
while(!inF2.eof()){
getline(inF2,songLine);
vector<string>temp(0);
//passes string vector in parse function BY REFERENCE
//I recreated the parse fuaction and disgraded the stringhelper function due to complications
parse(temp,songLine);
Song tempSong(temp[0],temp[1],temp[2],atoi(temp[3].c_str()),atoi(temp[4].c_str()));
tempPlistObj=tempPlistObj+tempSong;
}
//pushed temp playlist into the vector a of playlists
mp3.push_back(tempPlistObj);
}
do{
// cout # of playlists (need)
cout << "1 - Open an exisiting playlist" << endl
<< "2 - Create new list" << endl
<< "3 - Exit" << endl
<< "Selection: ";
cin >> choice1;
if(choice1==1){
//open existing playlist menu (need)
do{
//display list of playlists to choose from (need)
cin >> choice2;
for(int i=0; i< mp3.size(); i++){// for loop to check to see if choice matches any playlist
if(/*choice == playlist (need)*/1==1){
SongMenu(i);//runs song menu
choice2_flag=true;
}
}
if (choice2_flag==false){
cout << "Invalid Choice" << endl << endl;
}
}while(choice2_flag==false);
}
else if(choice1==2){
PlaylistMenu(); // run playlist menu
}
else if(choice1!=3){
cout << "Invalid entry. Please enter valid option" << endl << endl;
}
}while(choice1!=3);
return 0;
}