Monitoring sound

Scott Morrow scott at elementarysoftware.com
Mon Mar 21 04:29:38 EDT 2011


Hello Gerry,

From the docs:
"If no audio clip is playing, the sound function returns done"

If you don't have any other sounds playing you could set up a  "send in time" loop to check if the sound was done which would be more efficient than using idle.

For example:

local lPendingMessageQueue

--> your code here
-- begin playing your sound here
send IsSoundDone to me in 200 millisec -- or whatever time span works best
-- capture the "send" message ID here if you want to cancel it later
put CR & the result after lPendingMessageQueue
--> more of your code here


command IsSoundDone
     if the sound is done then
          -- hide the button
	  -- possibly cancel any pending message IDs if this command is sent from multiple sources
          -- put empty into lPendingMessageQueue
     else
          -- check again in a little bit
          send IsSoundDone to me in 200 millisec -- or whatever time span works best
     end if	 
end IsSoundDone

Note: this is untested pseudo code off the cuff...


Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web       http://elementarysoftware.com/
email     scott at elementarysoftware.com
------------------------------------------------------



On Mar 21, 2011, at 12:59 AM, Gerry wrote:

> Hi again 
> 
> In iOS I have to monitor the playing of a sound while the user browses the app, going from one screen/card to the next. If a sound is playing, I show a button, but if the sound ends, I want the button to be hidden.
> 
> In Hypercard I would have used idle. Is that still a good way to implement this in LiveCode?
> 
> Cheers
> 
> Gerry 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list