forked from siddharthvaddem/MusicPlayer-PBL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
1426 lines (1398 loc) · 36.6 KB
/
main.cpp
File metadata and controls
1426 lines (1398 loc) · 36.6 KB
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <ctype.h>
#include <fstream>
#include <iomanip>
#include <string>
#include <Windows.h>
#include <unistd.h>
using namespace std;
typedef struct info
{
string artist;
string album;
string song;
string genre;
string link;
} Info;
struct playlist : info //Inheriting from info structure
{
struct playlist *next;
} * head;
typedef struct login
{
string username;
string password;
string masterplaylist;
} Login;
Login details[100];
int arr[100];
int size = 0;
string userplaylist;
void create_playlist_menu();
void edit_record_menu();
void play_playlist_menu();
void display_record_menu(Info data[]);
int readFile(Info data[], string filename);
void display_all_records(Info data[], int size);
void shuffle();
void randomize(int arr[], int);
void swap(int arr[], int, int);
string signin();
string signup();
void addLoginData(string, string, string);
int readLoginData(Login details[]);
//----------------------------------------------MAIN FUNCTION----------------------------------------------------
int main()
{
Info data[100];
int loginchoice;
bool entered = false;
system("color B5");
cout << "OPENING APPLICATION ";
for (int j = 0; j < 2; j++)
{
for (int i = 0; i < 3; i++)
{
cout << ".";
cout.flush();
sleep(1);
}
cout << "\b\b\b \b\b\b";
}
login:
cin.clear();
cin.sync();
system("CLS");
system("color F1");
cout << "WELCOME TO ZUNE " << endl;
cout << "SIGN IN TO CONTINUE- " << endl;
cout << "1>ALREADY HAVE AN ACCOUNT?" << endl;
cout << "2>CREATE NEW ACCOUNT" << endl;
cout << "3>QUIT APPLICATION" << endl;
cout << "ENTER YOUR CHOICE- ";
cin >> loginchoice;
cout << endl;
switch (loginchoice)
{
case 1: //call signin func
userplaylist = signin();
entered = true;
break;
case 2: //call signup function
userplaylist = signup();
entered = true;
break;
case 3:
system("color B5");
system("CLS");
cout << "CLOSING APPLICATION";
for (int i = 0; i < 3; i++)
{
cout << ".";
cout.flush();
sleep(1);
}
cout << "\b\b\b \b\b\b";
exit(0);
break;
default:
cout << "Invalid Input" << endl;
sleep(1);
break;
}
if (!entered)
{
goto login;
}
lbl:
int choice, subchoice;
string input;
cin.clear();
cin.sync();
system("CLS");
system("color E4");
cout << "MENU\n";
cout << "1>CREATE PLAYLIST" << endl;
cout << "2>DISPLAY RECORDS" << endl;
cout << "3>EDIT YOUR PLAYLIST" << endl;
cout << "4>PLAY YOUR PLAYLIST" << endl;
cout << "5>LOGOUT" << endl;
cout << "6>EXIT" << endl;
cout << "Enter your choice:";
cin >> choice;
cout << endl;
switch (choice)
{
case 1: //fucntion1
create_playlist_menu();
break;
case 2: //function2
display_record_menu(data);
break;
case 3: //function3
edit_record_menu();
break;
case 4: //function4
play_playlist_menu();
system("color F4");
break;
case 5: //function5
cout << "SURE YOU WANT TO LOGOUT (Y/N)?" << endl;
cin >> input;
cout << endl;
if (input == "Y" || input == "y")
{
goto login;
}
else
{
goto lbl;
}
break;
case 6: //function5
system("CLS");
system("color B5");
cout << "CLOSING APPLICATION...";
sleep(2);
exit(0);
break;
default:
cout << "INVALID INPUT" << endl;
sleep(1);
break;
}
goto lbl;
return 0;
}
//-------------------------------------------------CREATING A PLAYLIS--------------------------------------------
void write_to_playlist(playlist *song, string name)
{
ofstream fout;
fout.open(name);
if (!fout)
{
cout << "ERROR IN OPENING FILE" << endl;
}
else
{
while (song != NULL)
{
fout << song->song << "," << song->album << "," << song->artist << "," << song->genre << "," << song->link << "\n";
song = song->next;
}
}
fout.close();
}
void create_playlist_menu()
{
Info data[20];
string name, song_name;
playlist *new_song, *song;
int size, choice;
head = NULL;
system("CLS");
cout << "ENTER THE NAME OF THE PLAYLIST:";
cin >> name;
cout << endl;
name = userplaylist + name + ".csv";
ofstream fout;
fout.open(userplaylist + ".csv", ios::app);
fout << name << "\n";
fout.close();
size = readFile(data, "dummy.csv");
lbl:
cin.clear();
cin.sync();
system("CLS");
cout << "Menu" << endl;
cout << "1>DISPLAY AVAILABLE SONGS" << endl;
cout << "2>ADD SONG TO PLAYLIST" << endl;
cout << "3>VIEW SONGS IN CURRENT PLAYLIST" << endl;
cout << "4>SAVE THE PLAYLIST" << endl;
cout << "ENTER YOUR CHOICE:";
cin >> choice;
cout << endl;
cin.clear();
cin.sync();
bool notfound = true;
switch (choice)
{
case 1:
display_all_records(data, size);
break;
case 2:
cout << "ENTER THE NAME OF THE SONG TO BE ADDED:";
getline(cin, song_name);
notfound = true;
for (auto &c : song_name)
{
c = tolower(c);
}
for (int i = 0; i < size; i++)
{
for (auto &c : data[i].song)
{
c = tolower(c);
}
if (data[i].song == song_name)
{
new_song = new playlist();
new_song->song = data[i].song;
new_song->album = data[i].album;
new_song->artist = data[i].artist;
new_song->genre = data[i].genre;
new_song->link = data[i].link;
new_song->next = NULL;
notfound = false;
if (head == NULL)
{
head = new_song;
}
else
{
playlist *temp;
temp = head;
head = new_song;
new_song->next = temp;
}
}
}
if (notfound){
cout << "song not found" << endl;
sleep(2);
}
break;
case 3:
song = head;
while (song != NULL)
{
cout << song->song << "," << song->album << "," << song->artist << "," << song->genre << "\n";
song = song->next;
}
sleep(4);
break;
case 4:
write_to_playlist(new_song, name);
delete new_song;
cout << "SAVING PLAYLIST";
for (int i = 0; i < 3; i++)
{
cout << ".";
cout.flush();
sleep(1);
}
cout << "\b\b\b \b\b\b";
system("color 2E");
system("CLS");
cout << endl;
cout << "PLAYLIST SAVED" << endl;
sleep(2);
system("color F4");
system("CLS");
return;
break;
default:
cout << "INVALID INPUT";
sleep(1);
break;
}
goto lbl;
}
//------------------------------------EDIT PLAYLIST-------------------------------------------------------------
void insert_song()
{
cin.clear();
cin.sync();
string search, playlistName, filename = userplaylist + ".csv";
bool notfound = true;
cout << "ENTER THE NAME OF THE PLAYLIST YOU WANT TO INSERT THE SONG INTO:";
getline(cin, search);
for (auto &c : search)
{
c = tolower(c);
}
cout << endl;
ifstream fin(filename);
if (!fin)
{
cout << "FILE COULDN'T BE OPENED!!" << endl;
sleep(1);
}
else
{
search = userplaylist + search + ".csv";
while (!fin.eof())
{
getline(fin, playlistName);
for (auto &c : playlistName)
{
c = tolower(c);
}
if (search == playlistName)
{
notfound = false;
break;
}
}
}
if (notfound)
{
cout << "PLAYLIST NOT FOUND, PLEASE CREATE PLAYLIST AND THEN TRY!!" << endl;
sleep(1);
return;
}
fin.close();
lblelse:
cin.clear();
cin.sync();
fstream fio(search, ios::in | ios::out | ios::app);
if (!fio)
{
cout << "ERROR IN OPENING FILE!!" << endl;
sleep(1);
}
else
{
Info data_song_list[30], data_song_playlist[30];
string songname;
cout << "Enter THE NAME OF THE SONG YOU WOULD LIKE TO ADD:";
getline(cin, songname);
for (auto &c : songname)
{
c = tolower(c);
}
bool songnotfound = true;
int size = readFile(data_song_list, "dummy.csv");
for (int i = 0; i < size; i++)
{
string song_name = data_song_list[i].song;
for (auto &c : song_name)
{
c = tolower(c);
}
if (songname == song_name)
{
int size_playlist = readFile(data_song_playlist, search);
for (int j = 0; j < size_playlist; j++)
{
string song_name_playlist = data_song_playlist[j].song;
for (auto &c : song_name_playlist)
{
c = tolower(c);
}
if (songname == song_name_playlist)
{
cout << "SONG ALREADY EXISTS IN PLAYLIST ,ADD A DIFFERENT SONG!!" << endl;
sleep(1);
songnotfound = false;
fio.close();
goto lblelse;
}
}
if (songnotfound)
{
fio << data_song_list[i].song << "," << data_song_list[i].album << "," << data_song_list[i].artist << "," << data_song_list[i].genre << "," << data_song_list[i].link << "\n";
cout << "\nSONG INSERTED\n";
fio.close();
sleep(2);
break;
}
}
}
}
}
void remove_song()
{
cin.clear();
cin.sync();
string search, playlistName, filename = userplaylist + ".csv";
bool notfound = true;
cout << "ENTER THE NAME OF THE PLAYLIST YOU WANT TO DELETE THE SONG FROM:";
getline(cin, search);
for (auto &c : search)
{
c = tolower(c);
}
cout << endl;
ifstream fin(filename);
if (!fin)
{
cout << "FILE COULDN'T BE OPENED!!" << endl;
sleep(1);
}
else
{
search = userplaylist + search + ".csv";
while (!fin.eof())
{
getline(fin, playlistName);
for (auto &c : playlistName)
{
c = tolower(c);
}
if (search == playlistName)
{
notfound = false;
break;
}
}
}
if (notfound)
{
cout << "PLAYLIST NOT FOUND , CREATE ONE AND TRY AGAIN!!" << endl;
sleep(1);
return;
}
fin.close();
int pos;
string songname;
Info data_song_playlist[20];
bool songnotfound = true;
cout << "ENTER THE NAME OF THE SONG TO BE REMOVED:";
getline(cin, songname);
for (auto &c : songname)
{
c = tolower(c);
}
cout << endl;
int size = readFile(data_song_playlist, search);
for (int i = 0; i < size; i++)
{
string song_name_playlist = data_song_playlist[i].song;
for (auto &c : song_name_playlist)
{
c = tolower(c);
}
if (songname == song_name_playlist)
{
songnotfound = false;
pos = i;
break;
}
}
if (songnotfound)
{
cout << "SONG NOT FOUND IN THE PLAYLIST!!" << endl;
sleep(1);
return;
}
ofstream fio;
fio.open(search);
for (int i = 0; i < size - 1; i++)
{
if (i == pos)
{
continue;
}
else
{
fio << data_song_playlist[i].song << "," << data_song_playlist[i].album << "," << data_song_playlist[i].artist << "," << data_song_playlist[i].genre << "," << data_song_playlist[i].link << "\n";
}
}
cout << "SONG DELETED\n";
fio.close();
sleep(2);
}
void edit_record_menu()
{
lbl:
int subchoice;
cin.clear();
cin.sync();
system("CLS");
cout << "EDIT RECORDS MENU" << endl;
cout << "1>INSERT SONG INTO YOUR PLAYLIST" << endl;
cout << "2>REMOVE SONG FROM YOUR PLAYLIST" << endl;
cout << "3>RETURN TO MAIN MENU" << endl;
cout << "ENTER YOUR CHOICE:";
cin >> subchoice;
cout << endl;
switch (subchoice)
{
case 1: //subfunction1
system("CLS");
insert_song();
break;
case 2: //subfunction2
system("CLS");
remove_song();
break;
case 3:
system("CLS");
return;
break;
default:
cout << "INVALID INPUT" << endl;
sleep(1);
system("CLS");
break;
}
goto lbl;
}
//-----------------------------------------DISPLAY RECORDS----------------------------------------------------
void display_playlist()
{
cout << "YOUR PLAYLIST'S ARE:" << endl;
string filename = userplaylist + ".csv", playlistName;
ifstream fin(filename);
if (!fin)
{
cout << "FILE COULDN'T BE OPENED!!" << endl;
sleep(1);
}
else
{
while (!fin.eof())
{
getline(fin, playlistName);
if (playlistName.length() != 0)
{
playlistName = playlistName.erase(0, userplaylist.length());
int length = playlistName.length() - 4;
playlistName = playlistName.erase(length);
cout << playlistName << endl;
}
}
}
sleep(3);
fin.close();
}
void filter_records()
{
int Subchoice;
Info filtered[100], temp[100];
lbl2:
string read, search, trash;
ifstream fin;
bool notfound = true;
int i = 0, a = 0;
cin.clear();
cin.sync();
system("CLS");
cout << "FILTER BY -" << endl;
cout << "1>ARTIST " << endl;
cout << "2>SONG " << endl;
cout << "3>ALBUM " << endl;
cout << "4>GENRE " << endl;
cout << "5>RETURN TO PREVIOUS MENU" << endl;
cout << "ENTER YOUR CHOICE ";
cin >> Subchoice;
cout << endl;
cin.sync();
switch (Subchoice)
{
case 1: //filter by artist
system("CLS");
fin.open("dummy.csv");
if (!fin)
{
cout << "FILE COULDN'T BE OPENED" << endl;
sleep(1);
}
else
{
cout << "ENTER THE NAME OF THE ARTIST:";
getline(cin, search);
for (auto &c : search)
{
c = tolower(c);
}
cout << endl;
while (!fin.eof())
{
getline(fin, temp[i].song, ',');
getline(fin, temp[i].album, ',');
getline(fin, read, ',');
for (auto &c : read)
{
c = tolower(c);
}
if (read == search)
{
for (auto &c : read)
{
c = toupper(c);
}
notfound = false;
filtered[i].song = temp[i].song;
filtered[i].album = temp[i].album;
filtered[i].artist = read;
getline(fin, temp[i].genre, ',');
getline(fin, temp[i].link, '\n');
filtered[i].genre = temp[i].genre;
filtered[i].link = temp[i].link;
if (a == 0)
{
cout << " Results for " << filtered[i].artist << "-" << endl;
cout << "SONG" << setw(30) << "ALBUM" << setw(30) << "GENRE" << endl;
a++;
}
cout << filtered[i].song << setw(30) << filtered[i].album << setw(30) << filtered[i].genre << endl;
sleep(0.5);
}
else
{
getline(fin, trash, '\n');
}
i++;
}
sleep(3);
if (notfound)
{
cout << "NO RESULTS FOUND" << endl;
sleep(1);
}
}
fin.close();
break;
case 2: //filter by song
system("CLS");
fin.open("dummy.csv");
if (!fin)
{
cout << "FILE COULDN'T BE OPENED" << endl;
sleep(1);
}
else
{
cout << "ENTER THE NAME OF THE SONG:";
getline(cin, search);
for (auto &c : search)
{
c = tolower(c);
}
cout << endl;
while (!fin.eof())
{
getline(fin, read, ',');
for (auto &c : read)
{
c = tolower(c);
}
if (read == search)
{
for (auto &c : read)
{
c = toupper(c);
}
notfound = false;
filtered[i].song = read;
getline(fin, temp[i].album, ',');
getline(fin, temp[i].artist, ',');
getline(fin, temp[i].genre, ',');
getline(fin, temp[i].link, '\n');
filtered[i].album = temp[i].album;
filtered[i].artist = temp[i].artist;
filtered[i].genre = temp[i].genre;
filtered[i].link = temp[i].link;
if (a == 0)
{
cout << "Results for " << filtered[i].song << "- " << endl;
cout << "ARTIST" << setw(30) << "ALBUM" << setw(30) << "GENRE" << endl;
a++;
}
cout << filtered[i].artist << setw(30) << filtered[i].album << setw(30) << filtered[i].genre << endl;
sleep(0.5);
}
else
{
getline(fin, trash, '\n');
}
i++;
}
sleep(3);
if (notfound)
{
cout << "NO RESULTS FOUND" << endl;
sleep(1);
}
}
fin.close();
break;
case 3: //filter by album
system("CLS");
fin.open("dummy.csv");
if (!fin)
{
cout << "FILE COULDN'T BE OPENED" << endl;
sleep(1);
}
else
{
cout << "ENTER THE NAME OF THE ALBUM:";
getline(cin, search);
cout << endl;
for (auto &c : search)
{
c = tolower(c);
}
while (!fin.eof())
{
getline(fin, temp[i].song, ',');
getline(fin, read, ',');
for (auto &c : read)
{
c = tolower(c);
}
if (read == search)
{
for (auto &c : read)
{
c = toupper(c);
}
notfound = false;
filtered[i].song = temp[i].song;
filtered[i].album = read;
getline(fin, temp[i].artist, ',');
getline(fin, temp[i].genre, ',');
getline(fin, temp[i].link, '\n');
filtered[i].artist = temp[i].artist;
filtered[i].genre = temp[i].genre;
filtered[i].link = temp[i].link;
if (a == 0)
{
cout << "Results for the album " << filtered[i].album << "- " << endl;
a++;
}
cout << filtered[i].song << endl;
sleep(0.5);
}
else
{
getline(fin, trash, '\n');
}
i++;
}
sleep(3);
if (notfound)
{
cout << "NO RESULTS FOUND" << endl;
sleep(1);
}
}
fin.close();
break;
case 4: //filter by genre
system("CLS");
fin.open("dummy.csv");
if (!fin)
{
cout << "FILE COULDN'T BE OPENED" << endl;
sleep(1);
}
else
{
cout << "ENTER THE GENRE YOU WOULD LIKE TO SEARCH:";
getline(cin, search);
for (auto &c : search)
{
c = tolower(c);
}
cout << endl;
while (!fin.eof())
{
getline(fin, temp[i].song, ',');
getline(fin, temp[i].album, ',');
getline(fin, temp[i].artist, ',');
getline(fin, read, ',');
for (auto &c : read)
{
c = tolower(c);
}
if (read == search)
{
getline(fin, temp[i].link, '\n');
for (auto &c : read)
{
c = toupper(c);
}
notfound = false;
filtered[i].genre = read;
filtered[i].song = temp[i].song;
filtered[i].artist = temp[i].artist;
filtered[i].album = temp[i].album;
filtered[i].link = temp[i].link;
if (a == 0)
{
cout << "Results for the genre " << filtered[i].genre << "- " << endl;
cout << "SONG" << setw(30) << "ARTIST" << endl;
a++;
}
cout << filtered[i].song << setw(30) << filtered[i].artist << endl;
sleep(0.5);
}
else
{
getline(fin, trash, '\n');
}
i++;
}
sleep(3);
if (notfound)
{
cout << "NO RESULTS FOUND" << endl;
sleep(1);
}
}
fin.close();
break;
case 5:
system("CLS");
return;
break;
default:
cout << "INVALID INPUT" << endl;
sleep(1);
break;
}
goto lbl2;
}
void display_record_menu(Info data[])
{
lbl:
int subchoice;
int size;
cin.clear();
cin.sync();
system("CLS");
cout << endl
<< endl;
cout << "DISPLAY RECORDS" << endl;
cout << "1>DISPLAY ALL SONGS" << endl;
cout << "2>FILTER SONGS AND SEARCH" << endl;
cout << "3>DISPLAY YOUR PLAYLISTS " << endl;
cout << "4>RETURN TO MAIN MENU" << endl;
cout << "ENTER YOUR CHOICE:";
cin >> subchoice;
cout << endl;
switch (subchoice)
{
case 1: //subfunction1
system("CLS");
cout << "ALL RECORDS" << endl;
cout << endl;
size = readFile(data, "dummy.csv");
display_all_records(data, size);
break;
case 2: //subfunction2
system("CLS");
filter_records();
break;
case 3:
system("CLS");
display_playlist();
break;
case 4:
system("CLS");
return;
break;
default:
cout << "INVALID INPUT" << endl;
sleep(1);
system("CLS");
break;
}
goto lbl;
}
//------------------------------------------PLAY PLAYLIST------------------------------------------------------
void shuffle()
{
lbl3:
int choice, i = 0;
Info data[100];
bool notfound = true;
cin.clear();
cin.sync();
system("CLS");
string search, playlistName, filename = userplaylist + ".csv";
cout << "ENTER THE NAME OF THE PLAYLIST YOU WANT TO PLAY:";
getline(cin, search);
search = userplaylist + search + ".csv";
int size = readFile(data, search);
size = size - 1;
cout << size << endl;
int count = 0;
for (int i = 0; i < size; i++)
{
arr[i] = count;
count++;
}
randomize(arr, size);
lbl1:
string link = "open " + data[arr[i]].link + " alias MyFile";
int a = 0;
mciSendStringA(link.c_str(), NULL, 0, 0);
mciSendString(TEXT("play MyFile "), NULL, 0, 0);
lbl:
system("CLS");
if (a == 0)
{
cout << "Options\n1>PAUSE\n2>PLAY NEXT SONG\n3>PLAY PREVIOUS SONG\n4>CHOOSE ANOTHER PLAYLIST\n5>STOP\nENTER YOUR CHOICE:" << endl;
cout << "NOW playing " << data[arr[i]].song << " by " << data[arr[i]].artist << " ";
cout.flush();
for (int i = 0; i < 3; i++)
{
cout << ".";
cout.flush();
sleep(1);
}
cout << "\b\b\b \b\b\b";
cout << endl;
cin >> choice;
choice = choice + 1;
}
else
{
cout << "Options\n1>CONTINUE\n2>PAUSE\n3>PLAY NEXT SONG\n4>PLAY PREVIOUS SONG\n5>CHOOSE ANOTHER PLAYLIST\n6>STOP\nENTER YOUR CHOICE:" << endl;
cout << "NOW playing " << data[arr[i]].song << " by " << data[arr[i]].artist << " ";
cout.flush();
for (int i = 0; i < 3; i++)
{
cout << ".";
cout.flush();
sleep(1);
}
cout << "\b\b\b \b\b\b";
cin >> choice;
}
switch (choice)
{
case 1:
mciSendString(TEXT("play MyFile "), NULL, 0, 0);
break;
case 2:
a++;
mciSendString(TEXT("pause MyFile "), NULL, 0, 0);
break;
case 3:
if (i + 1 <= (size - 1))
{
i = i + 1;
mciSendString(TEXT("close MyFile"), NULL, 0, 0);
goto lbl1;
}
else
{
cout << "-.-.-" << endl;
i = 0;
mciSendString(TEXT("close MyFile"), NULL, 0, 0);
randomize(arr, size);
goto lbl1;
}
break;
case 4: