-
Notifications
You must be signed in to change notification settings - Fork 0
/
wav player
70 lines (64 loc) · 1.54 KB
/
wav player
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
#include<iostream>
#include<windows.h> //used for PlaySound function
#include<fstream> //used for file handling
#include <list>
#include <algorithm>
#define MAX 100
using namespace std;
list<string> my_audio_list;
list<string>::iterator it;
void add_list()
{
int choice = 1;
while(choice)
{
string audio;
cin >> audio; // accept audio
my_audio_list.push_back(audio);
cout << "want to add song\n"
<< "press one else 0:: ";
cin >> choice;
}
}
void show_list()
{
cout << "your music list is::\n";
for ( it = my_audio_list.begin() ; it!=my_audio_list.end(); ++it)
{
cout << "\t" << *it <<endl;
}
}
string play_wav()
{
string audiofile;
audiofile = my_audio_list.front();
my_audio_list.pop_front();
return audiofile;
}
int main()
{
char audiofile_char[50];
string audiofile_str;
char audio[100];
fstream fp;
//Enter name of a 'wav' audio file with .wav extension and make sure it is present in the folder where your program is saved.
cout << "enter number of song to be added:: ";
add_list();
show_list();
audiofile_str = play_wav();
fp.open(audiofile_str.c_str(), ios::in);
if (fp != NULL)
{ cout << "audio playing : \n" ;
PlaySound(audiofile_str.c_str(), NULL, SND_SYNC);
}
else
{
cout<<"\nAudio file couldn't run..!!";
cout<<"\nCheck the following things: \n "
<<"1. Your file is an original .wav audio file. \n "
<<"2. You have mentioned '.wav' extension in the name of file. "
<<"\n 3. It is present in the folder where your program is saved.";
}
fp.close();
return 0;
}