To Play ".wave" file with C++(Background music)

  • Thread starter andrew.smith.cpp
  • Start date
A

andrew.smith.cpp

Hello :)
how can i play a ".wav" file in C++.means with the help of the C++
code i just want to play a "a.wav" file more then 10 times. i just
want to play background music.
Can i do it in C++ ?
if yes then how ?

Thanks
 
D

Daniel Pitts

Hello :)
how can i play a ".wav" file in C++.means with the help of the C++
code i just want to play a "a.wav" file more then 10 times. i just
want to play background music.
Can i do it in C++ ?
if yes then how ?

Thanks
You can, but its not a simple question nor a simple solution. If you
are a beginner to C++, it is likely out of your league. I'm *not* a
beginner, and I would struggle with it :)
 
A

andrew.smith.cpp

You can, but its not a simple question nor a simple solution. If you
are a beginner to C++, it is likely out of your league. I'm *not* a
beginner, and I would struggle with it :)
Hello D :)
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
Boz of i have to play a music with the code of C++.
if u know then Tell Me How?
Thanks
 
D

Daniel Pitts

Hello D :)
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
Boz of i have to play a music with the code of C++.
if u know then Tell Me How?
Thanks
It depends on what OS/platform your targeting. There is no standard way
to do it.
 
A

andrew.smith.cpp

PlaySound will do the trick - or you could link to the media player
control if you want to do anything more clever. either way, you should
ask on one of the microsoft.public groups, rather than here.

Andy

again i m telling that i have "arch linux" and "g++" complier
 
J

James Kanze

(e-mail address removed) wrote in (e-mail address removed):
On May 7, 8:02 pm, Daniel Pitts [...]
I m Not a Beginner but i don't know anything about it.
i search its archive but all are showing "PlaySound" Function with the
"windows.h" header and i m user of "g++"
its not working there. so what should i use for it.
g++ works also in Windows and presumably is able to include
<windows.h> (if you have downloaded and installed the Windows
SDK first of course).
If you are not on Windows you have to find other means. On
Linux a simple bash script should be enough for such things,
no need for C++.

In general, if the goal is just to play some background music,
and no real interaction is involved, the best solution is likely
to be to figure out the system dependent command line request to
do it, and invoke that via the system() function. On most
systems, system() will return something which can later be
converted into a command line request to kill the process, if
that's needed as well. (On the systems I'm familiar with,
system returns the process id, and something like:

std::eek:stringstream cmd ;
cmd << "kill " << systemReturnValue ;
system( cmd.str().c_str() ) ;

can be used to stop the process.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top