Waiting while sound is playing

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
gjn1w07
Posts: 17
Joined: Mon Mar 31, 2008 3:59 pm

Waiting while sound is playing

Post by gjn1w07 » Tue Mar 08, 2011 5:01 pm

Hi there,

I'm writing a program that plays an audioclip, then waits for 2 seconds, then plays another audioclip, waits another 2 seconds, then plays a final audioclip. The audioclips themselves vary from 1.5 to around 3ish seconds. However, at the moment the code looks something like this:

play audioclip clip1.wav
wait 2 seconds
play audioclip clip2.wav
wait 2 seconds
play audioclip clip3.wav

The problem is that the wait functions execute from the beginning of the audioclip, rather than waiting till the audioclip is finished. So at best the audioclips play end to end, and sometimes a clip is stopped so a new one can start. How can I do what I actually want to do? I have a feeling the playstopped message comes into it somewhere but my understanding of the code isn't good enough yet to figure out how!

Any help would be greatly appreciated.

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Waiting while sound is playing

Post by Klaus » Tue Mar 08, 2011 5:07 pm

Hi gjn1w07,

the magic word is "sound" and "done", OK the magic wordS ARE "sound" and "done" :D

...
## ac = abbreviation for audioclip
play ac "clip1.wav"
wait until the sound is "done"
play ac "clip2.wav"
wait until the sound is "done"
play ac "clip3.wav"
...

Hint: Get used to put QUOTES around names! Remember Murphys law 8)


Best from germany

Klaus

gjn1w07
Posts: 17
Joined: Mon Mar 31, 2008 3:59 pm

Re: Waiting while sound is playing

Post by gjn1w07 » Tue Mar 08, 2011 5:42 pm

Awesome - that's exactly what I needed. Thank you so much. I was starting to get into overly complicated ways to do it, like having a player object to put the sounds into and then put in a wait command based on the duration of the player.

Greg

Post Reply