How can I do that? Is there any examples, demos or manual?
Have you never worked with threads before? Just create a class derived from
TThread and override its virtual Execute() method.
Multithreaded Application TutorialFor example:
type
TMyThread = class(TThread)
protected
FSounds: TStringList;
procedure Execute; override;
public
constructor Create(const ASounds: array of String); reintroduce;
destructor Destroy; override;
end;
constructor TMyThread.Create(const ASounds; array of String);
var
I: Integer;
begin
inherited Create(False);
FreeOnTerminate := True;
FSounds := TStringList.Create;
for I := Low(ASounds) to High(ASounds) do
FSounds.Add(ASounds[I]);
end;
destructor TMyThread.Destroy;
begin
FSounds.Free;
inherited;
end;
procedure TMyThread.Execute;
var
I: Integer;
begin
I := 0;
while (I < FSounds.Count) and (not Terminated) do
sndPlaySound(PChar(FSounds[I]), SND_NODEFAULT or SND_SYNC);
end;
Then you can do this when needed:
TMyThread.Create([soundAddress1, soundAddress2, soundAddress3]);
Of course, this is just a simple example. In a real world application, you will probably want a queue that you can push sounds into, and then have the thread running continuously in the background polling sounds from the queue and playing them.