players versus play

Scott Rossi scott at tactilemedia.com
Sun Dec 9 14:10:00 EST 2001


Recently, mark mitchell wrote:

> I cannot figure out an easy way to do the
> 
> --wait until sound() is "done"
> 
> using the player objects.  The playStopped message is sent to the player
> object itself.  I've thus tried making a function handler in the card
> script, which responds to a message passed by the player object and then
> returns "stopped" or something, and then calling this function in the
> actual handler scripts where I want the wait to occur...but whew!  It
> didn't seem to work and there has gotta be a better way!

What exactly are you trying to achieve?

If you're simply trying to "pause" your script until the player is done, you
can use "wait with messages" and query the paused state of the player.  For
example:

  on playMyStuff
     # my code here
     # more code here
     start player myPlayer
     wait until the paused of player myPlayer with messages
     # yet more code here
  end playMyStuff

This will allow users to interact with your stack during the "wait".


If you're trying to add a delay between when the player stops and when you
execute your next action, you can use playStopped to auto-detect when a
player has stopped.  You can put in the card script:

  on playStopped
     send "doMyStuff" to me in 2 seconds
  end playStopped


Then your play handler:

  on playMyStuff
     # my code here
     # more code here
     start player myPlayer
  end playMyStuff

  on doMyStuff
     # do my cool stuff
  end doMyStuff


Regards,

Scott Rossi
Creative Director

Tactile Media, Multimedia & Design
Email: scott at tactilemedia.com
Web: www.tactilemedia.com




More information about the metacard mailing list