How to play a wav-File in Delphi?

audio, delphi, windows

Solution

Here's the fastest way:

uses MMSystem;

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

procedure TForm1.Button2Click(Sender: TObject);
begin
  sndPlaySound(nil, 0); // Stops the sound
end;

Problem

Which functions are available within Delphi to play a sound-file?

Original source