Sequencing the playing of sounds via players

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DougN
Posts: 20
Joined: Wed Mar 04, 2009 4:09 am

Sequencing the playing of sounds via players

Post by DougN » Sun Feb 14, 2010 8:12 pm

Hello,

I'm trying to upgrade some simple code to get rid of the evil "wait" command, and I thought I'd use it to learn about using the "send" system.

My old code:

Code: Select all

global knockResponse -- set with a pull-down menu on the card
on mouseup
   start player "knock"
   wait 2 seconds
   start player "knockAgain"
   wait 4 seconds
   start player knockResponse -- where knockResponse is a variable
end mouseup
My new approach, using the send command, looks like this:

Code: Select all

global knockResponse -- set with a pull-down menu on the card
on mouseup
   start player "knock"
   send "start player knockAgain" to me in 2 seconds
   send "start player knockResponse" to me in 6 seconds -- where knockResponse is a variable
end mouseup
This works great for the first two players ("knock" and "knockAgain"), but it doesn't work for the variable knockResponse (no sound plays) -- presumably because Rev is looking for a player that's actually named "knockResponse."

So my questions:

1) Am I approaching this in a good way, using the send command? Are there better ways to approach the sequencing of player playback?

2) Are there different ways to send the "start player" message? I tried -- send "start" to player "knock" -- but that didn't work.

3) Is there a way to include / use the variable name in the send command, so that I can vary the knockResponse sound that actually gets played, based on the value of the button?

Thanks, as always!
DougN

DougN
Posts: 20
Joined: Wed Mar 04, 2009 4:09 am

Re: Sequencing the playing of sounds via players

Post by DougN » Sun Feb 14, 2010 9:12 pm

OK, I think I found a way around this one:
3) Is there a way to include / use the variable name in the send command, so that I can vary the knockResponse sound that actually gets played, based on the value of the button?
Instead of using different players on the card, I'm going to use one player for the knockResponse, and change the file that it plays using the "set the filename of player knockResponse" command. I'll have the button where the user chooses the response set the filename.

I'd still be interested to know whether I can include a variable in a "send" command.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4002
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Sequencing the playing of sounds via players

Post by bn » Mon Feb 15, 2010 11:45 am

Hi DougN,
try:

Code: Select all

 send "start player" && knockResponse to me in 6 seconds -- where knockResponse is a variable
this way you send the content of the variable knockResponse along with the send command and you can choose the player with the variable. Everything that is within quotes Rev takes literally and has no idea about the variable. If you take your variablename out of the quote Rev uses the content of the variable.
regards
Bernd

DougN
Posts: 20
Joined: Wed Mar 04, 2009 4:09 am

Re: Sequencing the playing of sounds via players

Post by DougN » Tue Feb 16, 2010 12:04 am

Bernd,

Thanks! That's a great tip that I'll use in other situations as well.

Best,
Doug

Post Reply

Return to “Multimedia”