PDA

View Full Version : How end wave-playing detect ?



ijcro
08-06-2004, 11:47 AM
Please how end wave-playing detect ? Similar OnExit :oops: . Thanks

cairnswm
08-06-2004, 12:32 PM
I was not able to find a way of doing it so I just make a sound object that knows when it started and how long the sound is. When the time is up it triggers an event.

ijcro
08-06-2004, 08:17 PM
And how hooked the sound buffer when is cleared/destroyed ? It is possible way ? DelphiX hasn't encapsulated it well :(

cairnswm
09-06-2004, 06:54 AM
My object was seperate from the buffer.

Here is an example fo what I mean typed straight into the editor so possible errors in syntax and class names.

TSoundMonitor = Class
Sound : TDXWAVCollectionItem;
StartTime : Cardinal;
SoundLength : Cardinal;
OnEnd : TNotifyEvent;
Procedure Play;
Procedure Check;
End;

Procedure TSoundMonitor.Play;
Begin
StartTime := GetTickCount;
Sound.Play;
End;

Procedure TSoundMonitor.Check;
Begin
If GetTickCount-StartTime > SoundLength then
If Assigned(OnEnd) then
OnEnd(Self);
End;

--------------------

Procedure TForm1.Timer1Time(Sender : TObject);
Begin

// Draw Screen

For I := 0 to SoundItems.Count-1 do
TSoundMonitor(SoundItems[I]).Check;
End;

Procedure TForm1.PlaySound(NewSound : TDXWAVCollectionItem; NewSoundLength : Cardinal);
Begin
Sound := TSoundMonitor.Create;
Sound.Sound := NewSound;
Sound.SoundLength := NewSoundLength;
Sound.Play;
End;


Hope that makes it more clear.

Huehnerschaender
13-08-2004, 09:43 AM
Take a look at DSPack components. It capsulates all the DirectShow stuff in components. And it also has events when files end.

http://sourceforge.net/projects/dspack

Greetings,
Dirk