Delphi Sounds

rpm_bmbz
rpm_bmbz used Ask the Experts™
on
I want to play a 2 second *.wav file while my splash screen is loading but I cant the the mediaplayer component to work...
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
wkz

Commented:
maybe its the loading of the program itself that jams up the *.wav file. did you try putting the mediaplayer component on another thread and running it from there?

Commented:
uses MMSystem,



 sndPlaysound('E:\2.wav',SND_FILENAME+SND_RESOURCE);


use this API to play the wav file
have u tried  
 
procedure TForm1.FormCreate(Sender: TObject);
begin
//MediaPlayer1.FileName:= ...    (only needed if u haven't set the file in the object inspector)
MediaPlayer1.AutoRewind:=False;
MediaPlayer1.Open;
MediaPlayer1.Play;
end;

Author

Commented:
I'm trying your suggestions i'll get back with you shortly
I agree with dopors that sndPlaysound is a quick and easy way to do this. You could also use it with these parameters though:

sndPlaysound('intro.wav', SND_FILENAME+SND_ASYNC);

Replace SND_FILENAME with SND_RESOURCE if your are loading the sound from resources within your executable and use the resource name.

The SND_ASYNC means it will (well at least try to) play as your programs gets on with other things. It probably depends on how long you intend on displaying the splash screen and how much initialisation you have to do.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial