Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear all,

I am very new to C++ with MFC Programming.
I am doing a school project which is to build a .WAV player using C++ with MFC. I must use the lower level API BUT CANNOT simply a call to "PlaySound(_T("filename.wav"), NULL, SND_FILENAME | SND_ASYNC);" to play the .WAV file.

The "play" function is already implemented, however, I don't konw how to implement the "stop" function, as when I press the "play" button (which trigger the "play" function), the "play" function LOCKs all other buttons, I cannot press the "stop" button to stop the music playing.

Are there any hints for me to implement such a "stop" function? Is it something related to "asynchronous", "multi-threading" or something else?

THANKS IN ADVANCE for any valuable reply.
Posted

1 solution

As in http://www.cplusplus.com/forum/windows/96349/[^] already said, you need to post some code - it is very unusual behavior of a PlaySound with flag SND_ASYNC !

Anyway you don't need any new thread and you can stop sound with:

C++
PlaySound(NULL, 0, 0);
 
Share this answer
 
Comments
Allen Ho 20-Mar-13 13:49pm    
Sorry about my misleading presentation:
my school project prohibit us to call function like "PlaySound(NULL, 0, 0);" to manipulate the
.wav file. We have to write functions to read the .wav file and then parse the information stored in the .wav file, in order to play them.

(P.S. I can successfully play and stop the music when I call the following function from "mmsystem.h":
to play the music:
PlaySound(_T("filename.wav"), NULL, SND_FILENAME | SND_ASYNC);
to stop the music:
PlaySound(NULL, NULL, 0);
)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900