Click here to Skip to main content
15,938,507 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want ask a question about how to use a "Multimedia Commands" directly to repeat-play a wavefile by mciSendCommand.

well, actually I know I could wait the "MM_MCINOTIFY" when Command MCI_PLAY with flags MCI_NOTIFY is done, and start a new play again. and playing will not be end unless I send "MCI_STOP" Command.

just like follow C language Code

1. play sound with MCI_NOTIFY
MCI_PLAY_PARMS parmPlay;
static BOOL    bRepeat;

parmRec.dwCallback = hwnd;
parmRec.dwFro      = 0;
parmRec.dwTo       = 0;

bRepeat = TRUE ;

mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)&parmPlay);

2. Receive NOTIFY Message when Playing done
case MM_MCINOTIFY:

switch (wParam)
{
case MCI_NOTIFY_SUCCESSFUL:

     if (bRepeat)//start new Play again
     {
         mciSendCommand(wDeviceID, MCI_PLAY, MCI_NOTIFY,
                       (DWORD)&parmPlay);
     }

     return TRUE ;
}

break ;

I want to know if Can I use a MCI-command directly to repeat-play by mciSendCommand.
Posted
Updated 27-Dec-10 22:22pm
v8

i didn't find anything with mci commands for repeating the play.
sndPlaySound has an option for that (SND_LOOP).
 
Share this answer
 
Comments
tanakahitori 28-Dec-10 0:28am    
thanks you , I think so
Dalek Dave 28-Dec-10 2:19am    
Seems reasonable
actually I know could use "waveOutOpen" to repeat-play wavefile easy too.

1. Open waveOut-Device

static HWAVEOUT     hWaveOut ;
static WAVEFORMATEX waveform ;

//assume wavefile is record in single channel and 8-bit, 11.025 kHz

waveform.wFormatTag      = WAVE_FORMAT_PCM ;
waveform.nChannels       = 1 ;
waveform.nSamplesPerSec  = 11025 ; //11025 Hz
waveform.nAvgBytesPerSec = 11025 ; //11025 Hz
waveform.nBlockAlign     = 1 ;
waveform.wBitsPerSample  = 8 ;
waveform.cbSize          = 0 ;

waveOutOpen (&hWaveOut, WAVE_MAPPER, &waveform,
            (DWORD) hwnd, 0, CALLBACK_WINDOW) ;

//"waveOutOpen" sent "MM_WOM_OPEN" in message-queue
//hwnd will receive it ,which is specified in "waveOutOpen"

2. MM_WOM_OPEN
static PWAVEHDR     pWaveHdr ;
static DWORD        dwRepetitions = 1; //play 1 time when Init
static BOOL         bRpeat = TRUE ;

case MM_WOM_OPEN:

if (bRpeat) dwRepetitions = -1 ; //"-1" means repeat.

pWaveHdr->lpData          = pBuffer ; //waveDate
pWaveHdr->dwBufferLength  = dwDataLength ;
pWaveHdr->dwBytesRecorded = 0 ;
pWaveHdr->dwUser          = 0 ;
pWaveHdr->dwFlags         = WHDR_BEGINLOOP | WHDR_ENDLOOP ;
pWaveHdr->dwLoops         = dwRepetitions ; //times of Playing
pWaveHdr->lpNext          = NULL ;
pWaveHdr->reserved        = 0 ;

//prepare Buffer
waveOutPrepareHeader (hWaveOut, pWaveHdr1, sizeof (WAVEHDR)) ;

//send Buffer to waveOut-Device to start playing
waveOutWrite (hWaveOut, pWaveHdr1, sizeof (WAVEHDR)) ;

//the playing doesn't stop unless call waveOutPause or waveOutReset
// hwnd will receive MM_WOM_DONE, when playing stopped

I just wonder why MciSendCommand didnt design a Command can repeat to play...
 
Share this answer
 
v2
Comments
jk chan 28-Dec-10 5:32am    
but they had provided an option using MCI_NOTIFY right ?

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