Alxplay callback when done?
by Shai Perry · in Torque Game Engine · 06/26/2006 (3:26 pm) · 4 replies
Hi,
I was wondering if there is a way to get a callback when alxplay is finished playing a sound.. ?
Thanks,
I was wondering if there is a way to get a callback when alxplay is finished playing a sound.. ?
Thanks,
#2
06/27/2006 (12:03 pm)
A callback when a sound is finished playing is an interesting idea. Of course it would never be completely accurate as the callback could delay as long as a single engine tick (32ms).
#3
Implementing such a callback mechanism should be simple enough, provided you have access to the source. I'd suggest calling a console function in the audio update loop, e.g. alxHandleFinished(). From there, you can determine which handle has stopped playing, and then, what to do next.
06/27/2006 (12:35 pm)
...not to mention the fact that openal processes seperate thread, potentially delaying the callback even further.Implementing such a callback mechanism should be simple enough, provided you have access to the source. I'd suggest calling a console function in the audio update loop, e.g. alxHandleFinished(
#4
06/27/2006 (6:49 pm)
Thanks guys
Torque 3D Owner James Spellman
function Foo::PlayIt( %this) { %this.audiofile = alxPlay(...); %this.Cycle(); }; function Foo::Cycle( %this) { if (alxisPlaying( %this.audiofile)) %this.schedule( 100, Cycle); else %this.schedule( 1000, Cue); }