Jump to content
  • Advertisement

Archived

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

Matt Ward

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

This topic is 5738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!