Archived

This topic is now archived and is closed to further replies.

Matt Ward

DelphiX - How to tell if a WAV is already playing.

Recommended Posts

Matt Ward    122
I can''t find this anywhere, I''m sure it''s simple. How do I tell if a WAV in my wavimagelist is already playing? I want to stop my program from replaying a sound effect if it''s already playing. Thanks. Matt

Share this post


Link to post
Share on other sites
ggs    166
Hmm, I remember addressing this question about a year ago. But with the search feature down I cant easily copy & paste the code I wrote that implmented the feature.

Basicly that feature is missing from sound library that comes with (Un)DelphiX.

I''ll post it latter when I find it.

Share this post


Link to post
Share on other sites
ggs    166
Couldnt find the article on the forums, so I managed to dig up a copy that was storied my my harddrive.

Enjoy!


  
Back up your existing copy of DXsounds.pas to something like ~DXsounds.pas.
In DXSounds.pas, Make the following changes:


Line 381 (in the TWaveCollectionItem class) Add:
*******
Protected
Function GetPlaying : boolean;
public
Property Playing : boolean read GetPlaying;
*******

At line 2230 Add:
*******
Function TWaveCollectionItem.GetPlaying : boolean;
var
Buffer : TDirectSoundBuffer;
index : integer;
begin
Result := false;
if not FInitialized then Exit;
assert(GetBuffer <> nil);
assert(FBufferList <> nil);
if FLooped then
begin
Buffer := GetBuffer;
assert(Buffer <> nil);
result := Buffer.Playing;
end
else
begin
for index := 0 to FBufferList.Count - 1 do
begin
result := TDirectSoundBuffer(FBufferList[index]).Playing;
if result then
Break;
end;
end;
end; {GetPlaying}
*******



[edited by - ggs on October 3, 2002 10:03:00 AM]

Share this post


Link to post
Share on other sites