Recent

Author Topic: [SOLVED]Lazarus SoundPlay won't work  (Read 657 times)

Eclipse123

  • Newbie
  • Posts: 2
[SOLVED]Lazarus SoundPlay won't work
« on: April 15, 2021, 03:05:19 pm »
Hi,
I'm having problems making sound work on my application. I'm using PlaySound with MMSystem, but when I run my app it makes the error sound and no music plays when it needs to.


Code: Pascal  [Select][+][-]
  1. procedure TForm3.FormCreate(Sender: TObject);
  2. begin
  3.   Score.Top := 0;
  4.   Score.Left := Form3.Width-70;
  5.   CatchMe.Top := Round(Form3.Height/2-30);
  6.   CatchMe.Left := Round(Form3.Width/2-100);
  7.   PlaySound('30sec_Track.wav',0,SND_ASYNC);
  8. end;
  9.  


The wav file is in the same folder at the application.
« Last Edit: April 15, 2021, 03:59:42 pm by Eclipse123 »

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Lazarus SoundPlay won't work
« Reply #1 on: April 15, 2021, 03:16:53 pm »
I don't know. Is the wav file defective?

This is working correctly for me:
Code: Pascal  [Select][+][-]
  1. uses
  2.   MMSystem;
  3.  
  4. procedure TForm1.Button1Click(Sender: TObject);
  5. begin
  6.   PlaySound(PChar('c:\Windows\Media\Alarm01.wav'), 0, SND_ASYNC);
  7. end;  

Eclipse123

  • Newbie
  • Posts: 2
Re: Lazarus SoundPlay won't work
« Reply #2 on: April 15, 2021, 03:26:55 pm »
I'm soo stu... I didn't add the file to the folder after i converted it to wav. Thanks for the help it works now and sorry for the mistake ahahah.

 

TinyPortal © 2005-2018