Delphi 3 playing a .wav file

Please can you give me the code to attach to a button's on click event handler that will enable me to play a (wav)sound file as i would like to add sounds to my applications. many thanks phil from London.
alixAsked:
Who is Participating?
 
itamarConnect With a Mentor Commented:
Hi alix,

just drop a TMediaPlayer (from System VCL pallete) in your form and make it invisible.

And the code is:

procedure TForm1.Button1Click(Sender: TObject);
begin
  MediaPlayer1.FileName := 'C:\WINDOWS\MEDIA\CHIMES.WAV';
  MediaPlayer1.Open;
  MediaPlayer1.Play;
end;

IHTH,
Itamar
0
 
viktornetCommented:
You can also do this....

PlaySound(PChar('The path'), 0, snd_Async);

Regards,
Viktor Ivanov
0
 
itamarCommented:
Well, follow this link to have a complete picture in this subject;

http://www.inprise.com/devsupport/delphi/ti_list/TI3099.html

ISTH (I'm Sure This Helps ;-D )
Itamar
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.