Click to See Complete Forum and Search --> : Playing and stopping WAVE is giving problem


Kaps
June 2nd, 1999, 03:13 AM
Hi,

My requirement is to play a wav file and stop it in between. I found some function like PlaySound(). from this I am able to play, but I don't have any way to stop it in between.

If anybody knows , pls tell me.

Best Regards,
Kapil

Lac Bui
June 2nd, 1999, 04:07 AM
You have 2 ways to do that :
The first use:
sndPlaySound(strFileName,SND_ASYNC | SND_LOOP |SND_NODEFAULT); // put it in place you wanr to begin play.
and
sndPlaySound(NULL,SND_ASYNC );// put it in place you want to stop.

The second you can use Thread:

UINT PlayThread( LPVOID pParam )
{
CString strFile;
strFile = ((CString)pParam);
sndPlaySound(strFile, SND_SYNC );

delete pParam;
return 0;
}
use :
AfxBeginThread(PlayThread, strFileName); // place you want to play sound
and
sndPlaySound(NULL,SND_ASYNC );// place you want to stop play.

If any comment, please give me your ideas.
Lac Bui
E_Mail: bmlactma@hotmail.com