Forum > General

Playing sound --- help---

<< < (2/2)

lazer:
This seamed to answer the question nicely but when I add MMSystem it fails to compile:


--- Quote ---Fatal: Cannot find MMSytem ...
--- End quote ---

Has this been renamed now?

Thanks.

Nicole:
There is a component known by the
package - online package manager
called PlaysoundPackage.

Install it.
It makes a control appear in the tab "LazControls" called "playsound".

Drop it on your form and it works "by itsself" (=intuitive to use).

KodeZwerg:

--- Quote from: albino on April 07, 2008, 10:03:39 pm ---Hello again, thanks for your answer and "sorry" here is my code. I tried this and it works:

uses MMSystem;

procedure TForm1.Button1Click(Sender: TObject);
begin
  sndPlaySound('C:\dog.wav',SND_NODEFAULT Or SND_ASYNC);
end;

Now my problem is loading a lrs file, I wrote this code but it doesn't work.

uses MMSystem;

initialization
{$I unit1.lrs}
{$I sounds.lrs}

procedure TForm1.Button1Click(Sender: TObject);

begin
  PlaySound('dog', hInstance, SND_RESOURCE or SND_SYNC);
end;

Thank you again.

--- End quote ---
For windows you can do it like here: (add waves in RCDATA section with built-in resource editor)

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);var  resStream: TResourceStream;begin  resStream := TResourceStream.Create(HINSTANCE, 'IDENTIFIER_NAME_OF_WAVE', RT_RCDATA);  try    PlaySound(PChar(resStream.Memory), 0, SND_MEMORY or SND_SYNC);  finally    resStream.Free;  end;end;

Navigation

[0] Message Index

[*] Previous page

Go to full version