Problem with "PlaySound()" Function????
-
i am using the PlaySound function -Platform SDK: Windows Multimedia- to play .wav files, the problem is i need to know when this function finish playing the sound file and F.Y.I. when (fdwSound) parameter is set to SND_ASYNC "asynchronously", the function return immediately after beginning the sound. also when (fdwSound) parameter is set to SND_SYNC "Synchronous", the function wait till it end the file playing and then return i want to know : 1 - when the function finished playing the file if the (fdwSound)param. is SND_ASYNC 2 - OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC thnx alot 4 ur time and concern !! it is good to be here
-
i am using the PlaySound function -Platform SDK: Windows Multimedia- to play .wav files, the problem is i need to know when this function finish playing the sound file and F.Y.I. when (fdwSound) parameter is set to SND_ASYNC "asynchronously", the function return immediately after beginning the sound. also when (fdwSound) parameter is set to SND_SYNC "Synchronous", the function wait till it end the file playing and then return i want to know : 1 - when the function finished playing the file if the (fdwSound)param. is SND_ASYNC 2 - OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC thnx alot 4 ur time and concern !! it is good to be here
-
Well, you could use PlaySound from a secondary thread, running synchronously then posting a thread message when it completes.
Steve S Developer for hire
that's not wat i want:doh: i want if it si running synchronously ---> to be able to stop the file playing:wtf: OR if it is running asynchronously ---> to detremine when the file finish playing:wtf: that's it;) i already able to know that the file finish playing when it is synchronously called cuz the function doesn't return untill it finish playing
-
that's not wat i want:doh: i want if it si running synchronously ---> to be able to stop the file playing:wtf: OR if it is running asynchronously ---> to detremine when the file finish playing:wtf: that's it;) i already able to know that the file finish playing when it is synchronously called cuz the function doesn't return untill it finish playing
Hi. Look for the mci functions like: mciSendString. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_mcisendstring.asp[^]
Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )
-
i am using the PlaySound function -Platform SDK: Windows Multimedia- to play .wav files, the problem is i need to know when this function finish playing the sound file and F.Y.I. when (fdwSound) parameter is set to SND_ASYNC "asynchronously", the function return immediately after beginning the sound. also when (fdwSound) parameter is set to SND_SYNC "Synchronous", the function wait till it end the file playing and then return i want to know : 1 - when the function finished playing the file if the (fdwSound)param. is SND_ASYNC 2 - OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC thnx alot 4 ur time and concern !! it is good to be here
singersinger wrote:
OR how can i stop playing the file if the (fdwSound)param. is SND_SYNC
PlaySound(NULL, 0, SND_PURGE) might do the trick if called from another thread.
We're the regulators that de-regulate We're the animators that de-animate
-
that's not wat i want:doh: i want if it si running synchronously ---> to be able to stop the file playing:wtf: OR if it is running asynchronously ---> to detremine when the file finish playing:wtf: that's it;) i already able to know that the file finish playing when it is synchronously called cuz the function doesn't return untill it finish playing
You want to be able to play it synchronously, yet be able to stop it playing. Can't do that, because PlaySound won't return until it's already finished. You want to play it asynchronously, and get notified when it's stopped playing. Can't do that, because PlaySound provides no notifications. However, if you read what I wrote, you can get the behaviours that you want. Spin another thread to call PlaySound synchronously. That thread can tell you when it's finished, and the effect on the other thread is that of playing it asynchronously. If you want to stop it playing, you can call playsound with a purge option (as someone else has suggested) from the original thread, which will give you what you want. Alternatively, you can try the MCI interface, or look at the waveOut* functions. However, using waveOut is a lot more complicated than using PlaySound with a second thread There's a phrase which comes to mind: If you won't like the answer, don't ask the question...
Steve S Developer for hire