kag0
asked on
play a wav??
how do I play a wav file in my program??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This is actually a Delphi code.....
PlaySound(PChar(ListBox1.I tems[ListB ox1.ItemIn dex]), 0, snd_Async);
which would be something like this in C++ Builder...
PlaySound(PChar(ListBox1-> Items[List Box1->Item Index]), 0, snd_Async);
I'm not sure if there is actually a PChar() but you figure it out...
Regards,
Viktor Ivanov
PlaySound(PChar(ListBox1.I
which would be something like this in C++ Builder...
PlaySound(PChar(ListBox1->
I'm not sure if there is actually a PChar() but you figure it out...
Regards,
Viktor Ivanov
ASKER
I'm way out of my league here, I hope to understand that answer someday, but for now, I'm lost.
An example program might put it into perspective for me.I'm using Borland 4.5.
An example program might put it into perspective for me.I'm using Borland 4.5.
ASKER
Adjusted points to 100
add a line to your program, along the lines of:
if(PlaySound( "c:\\windows\\media\\ding. wav", NULL, SND_FILENAME)==TRUE) { // sound played okay
} else { // trouble
}
Regards,
-Andy
if(PlaySound( "c:\\windows\\media\\ding.
} else { // trouble
}
Regards,
-Andy
ASKER
Compiling SOUNDTRY.CPP:
Error : Call to undefined function 'PlaySound' in function main()
Error: Undefined symbol 'SND_FILENAME' in function main()
void main(void){
if(PlaySound( "c:\\wavefiles\\clay.wav",
{}
else{}
}should this work??
any #includes i should add?
I can't do it.
ASKER
A beginner would know more about this than I do. I'll have to go back and finish learning C first I think. Here's a few extra points
#include <mmsystem.h>
You also need to link with winmm.lib.
You also need to link with winmm.lib.
Yes, it should work, as chensu says (and I forgot) you do need to include mmsystem.h, which defines PlaySound() and the matching symbols like SND_FILENAME. Additionally, you need to add winmm.lib to the list of files in your project (at least that's how VC++ works, perhaps Borland requires you to explicitly list it as a library). Don't worry, you're nearly there.
Regards,
Viktor Ivanov