Page 1 of 1

Wait until the sound is done

Posted: Tue Jan 11, 2022 9:08 am
by bbalmerTotalFluency
Hello:

The code in the subject line is not working for me on OSX Monterey using the livecode audio player object.

Is it me? Is it Monterey? Is it Livecode? I feel like a seagull covered in oil and am wondering if there is a way back to the skies. I've seen nothing on line to tell me what's up or what to do and thus I turn to the learned, the experienced and the helpful.

Bruce

Re: Wait until the sound is done

Posted: Tue Jan 11, 2022 10:15 am
by Klaus
Hi Bruce,

this will only work if you started your sound with -> play audioclip "the_sound.xxx"
It does not work with the player object.


Best

Klaus

Re: Wait until the sound is done

Posted: Tue Jan 11, 2022 11:45 am
by jmburnod
Hi Bruce,
What Klaus said
Works also with sound file.
Best
Jean-Marc

Re: Wait until the sound is done

Posted: Tue Jan 11, 2022 1:29 pm
by bbalmerTotalFluency
Klaus:

If my life were a hotdog - you would be the mustard relish that makes it all worthwhile. Thank you.

I thought that play had been deprecated and we were meant to use the player object these days?

Should I have been able to find this out for myself or is it just experience on your part?

Bruce

Re: Wait until the sound is done

Posted: Tue Jan 11, 2022 1:46 pm
by Klaus
Hi Bruce,
bbalmerTotalFluency wrote:
Tue Jan 11, 2022 1:29 pm
Klaus:

If my life were a hotdog - you would be the mustard relish that makes it all worthwhile. Thank you.
LOL :-D
You're welcome!
bbalmerTotalFluency wrote:
Tue Jan 11, 2022 1:29 pm
I thought that play had been deprecated and we were meant to use the player object these days?
No, PLAY AC is still supported. But since this only supports a very limited fileformats (UNCOMPRESSED wav and aiff files and the compressed-by-nature AU format, it may be seldom used.
bbalmerTotalFluency wrote:
Tue Jan 11, 2022 1:29 pm
Should I have been able to find this out for myself or is it just experience on your part?
Well, the dictionary does not explicitely mention this anywhere, so "thou shalt be forgiven" for not finding it! :-)


Best

Klaus

Re: Wait until the sound is done

Posted: Tue Jan 11, 2022 6:30 pm
by jacque
If you want to know when the player is finished you can handle the playStopped message.

Re: Wait until the sound is done

Posted: Tue Jan 11, 2022 6:34 pm
by Klaus
jacque wrote:
Tue Jan 11, 2022 6:30 pm
If you want to know when the player is finished you can handle the playStopped message.
Exactly! :D

And if you need to knwo if the sound really finished you can:

Code: Select all

...
put the duration of player "your sound here" into tDur
put the currenttime of player "your sound here" into tCur
if tDur = tCur then
  ## sound is really "done"
  ## do your thing...
end if
...
Just in case your user can stop the sound manually.