You are not logged in.

Dear visitor, welcome to Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Scott Witte


  • "Scott Witte" started this thread

Posts: 272

Location: Milwaukee, WI USA

Occupation: Professional Photographer

  • Send private message


Monday, November 18th 2019, 5:50pm

Getting sound position can end a sound

If you play a sound and immediately start a loop checking the play position, say for a progress indicator, you can "crash" or end the sound, actually firing the oncomplete event. to wit:

Source code


<action name="getposition">
     copy(sposition, sound[test].position);

If the sound isn't fully loaded you get "[object][object]" as the "position" and the loop continues. No foul. But try the above after the sound has played and you get a position of "0" which isn't possible once the sound has started to play. Problem is, the sound then ends before it starts and fires the oncomplete event. Not what you want.

My kludgy workaround is to delay starting the loop, giving the sound time to actually start before getting its position. I say kludgy because if you don't wait long enough -- perhaps if something unexpectedly delays the sound starting to play -- I suspect you could still have the problem.

Klaus -- Could the soundinterface code be changed to avoid this issue?

Anyway, whether this is a bug that can be fixed or a fact of life we have to live with, perhaps this post can help someone else avoid the hours it took me to run this down. Just keep telling yourself, "Coding is fun!"

Similar threads