Recent

Author Topic: [SOLVED]Lazarus SoundPlay won't work  (Read 236 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: 8415
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;  
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

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