[SOLVED] detect when sound has finished playing

LenseOnLife

  • Posts: 127
Hi All,

Wondering if it is possible to detect when a sound has finished.  I'm looking at a situation where it would be handy to play sounds in sequence depending on some boolean.  To do this, I'd have to be able to detect when a sound finishes playing.

Is this possible?

Cheers,

Oliver

« Last Edit: January 20, 2018, 12:02:22 pm by LenseOnLife »

Luyren

  • *
  • Posts: 2784
Using the blocks "get position for channel" and "get length of channel" or "get length of sound" you could do that. Haven't tested it, but one can assume that if the position of a sound channel is equal the length of the sound it is playing, then said channel has finished playing the sound.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

LenseOnLife

  • Posts: 127
Hi,

That's interesting - hadn't thought of that.

I'll give it a try and let you know.

thanks,

Oliver

LenseOnLife

  • Posts: 127
Hi,

Just tested it - yep, you were right.

Thanks,

Oliver

designpeg

  • *
  • Posts: 731
All good advice above, but I'd just like to add an issue I came across that caused me problems.  If you pause a channel, on flash the position block returns the position you pause at, but on ios the position block returns zero while the sound is paused. It's worth knowing about this small difference if you're planning to publish on ios - not sure about android or desktop behaviors.

LIBERADO

  • *
  • Posts: 2720
@designpeg, you could report it as a bug in the Issue Tracker
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.