Can somebody give me a piece of sample code of playing .wav file, please? 
Author Message
 Can somebody give me a piece of sample code of playing .wav file, please?

I want to play a .WAV file in VC++.
I tried it like this:
void CMyClockDlg::OnBUTTONStart()
{
 MCI_OPEN_PARMS open;
 open.lpstrDeviceType="waveaudio";
 open.lpstrElementName="Start.wav";
 mciSendCommand(NULL,MCI_OPEN,MCI_OPEN_TYPE,(DWORD)&open);
 mciSendCommand(open.wDeviceID,MCI_PLAY,MCI_FROM|MCI_WAIT,(DWORD)&open);
Quote:
}

There is a file named 'Start.wav' in the directory 'DEBUG' which contains
MYCLOCK.EXE. When I pressed the Button called 'ButtonStart', nothing
happened. What is the errors? Or would you please give me a piece of sample
code?
Thank you.


Tue, 30 Jul 2002 03:00:00 GMT  
 Can somebody give me a piece of sample code of playing .wav file, please?
The easy way would be:
PlaySound("Start.wav",NULL, SND_FILENAME | SND_ASYNC )

Cheers,

Mike

Quote:

> I want to play a .WAV file in VC++.
> I tried it like this:
> void CMyClockDlg::OnBUTTONStart()
> {
>  MCI_OPEN_PARMS open;
>  open.lpstrDeviceType="waveaudio";
>  open.lpstrElementName="Start.wav";
>  mciSendCommand(NULL,MCI_OPEN,MCI_OPEN_TYPE,(DWORD)&open);
>  mciSendCommand(open.wDeviceID,MCI_PLAY,MCI_FROM|MCI_WAIT,(DWORD)&open);
> }
> There is a file named 'Start.wav' in the directory 'DEBUG' which contains
> MYCLOCK.EXE. When I pressed the Button called 'ButtonStart', nothing
> happened. What is the errors? Or would you please give me a piece of sample
> code?
> Thank you.



Tue, 30 Jul 2002 03:00:00 GMT  
 Can somebody give me a piece of sample code of playing .wav file, please?
Thank you again! It's much easier than the way I read from the book. :-)


Quote:
> The easy way would be:
> PlaySound("Start.wav",NULL, SND_FILENAME | SND_ASYNC )

> Cheers,

> Mike



Tue, 30 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to play .wav file, Please

2. Student needs source code to play Wav files in Turbo C

3. WTD: Code to play .WAV files

4. Play WAV File From Resource File

5. Managed C++ and playing WAV files (sound)

6. playing wav files in linux

7. PLAY WAV FILES IN TURBO C [[[URGENT]]]

8. Playing/Recording Wav Files in C/C++ for Dos

9. playing a .wav file or other sound

10. Playing WAV files.

11. Playing wav files in C

12. Play wav files.

 

 
Powered by phpBB® Forum Software