tags:

views:

3152

answers:

4

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

+1  A: 

A full tutorial is available at: http://sheepdogguides.com/dt3f.htm

It is a bit old. But it should work.

Gamecat
Yup it still works in 2009.
Gamecat
+3  A: 

With the function sndPlaySound from the WIN32-API (Unit MMSystem):

sndPlaySound('C:\Windows\Media\Tada.wav', SND_ASYNC);

Name
+12  A: 

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;
hmemcpy
+1  A: 

This page explains quite good how to use the function sndPlaySound and how to embed the wav-file as a resource: http://www.latiumsoftware.com/en/delphi/00024.php

Name