Solved

Delphi 3 playing a .wav file

Posted on 1998-09-23
3
183 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:alix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
itamar earned 100 total points
ID: 1340705
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1340706
You can also do this....

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

Regards,
Viktor Ivanov
0
 
LVL 4

Expert Comment

by:itamar
ID: 1340707
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question