Embedding Sound with Flash, Part III: Streams: Checking for a Playing Track - Doc JavaScript
Embedding Sound with Flash, Part III: Streams
Checking for a Playing Track
FlashSound JavaScript API lets you check if a track is playing, by the IsPlaying()
method. The IsPlaying()
method has no arguments and it returns true
if the playhead is moving, false
otherwise. You can use this method to create innovative sound combinations. For example, you can play a sound track only if the other sound track is mute.
The left three out of the following four links mimic a typical tape recorder control panel. The right link checks if the playhead is moving along the timeline. Mouse over it and find out the answer to the question "IsPlaying?"
. The link at the second line plays a scale passage, but only if the tutorial is not playing. We do this conditional playing by checking that the tutorial's IsPlaying()
is false. The tutorial's object is mySoundObj1
, and the scale passage's object is mySoundObj2
. The conditional playing is:
if (!mySoundObj1.IsPlaying()) mySoundObj2.TGotoAndPlay('/scale-event', 'start')
Play around with the links. Start the tutorial. Try to play the scale and see that it does not play. Pause the tutorial. Try now to play the scale. See that it does play now. Continue the tutorial. Can you play the scale now?
Rewind and Play the Tutorial Pause Continue Is Playing?
Play A ScaleHere is the source code:
<HTML> <HEAD> <SCRIPT SRC="flashsound.js"></SCRIPT> <SCRIPT> var mySoundObj1 = new FlashSound(); var mySoundObj2 = new FlashSound(); </SCRIPT> </HEAD> <BODY> <P><A HREF="javascript://" onmouseover="mySoundObj1.TGotoAndPlay('/',1)"> Rewind and Play the Tutorial</A> <A HREF="javascript://" onmouseover="mySoundObj1.TStopPlay('/')">Pause</A> <A HREF="javascript://" onmouseover="mySoundObj1.TPlay('/')">Continue</A> <A HREF="javascript://" onmouseover="alert(mySoundObj1.IsPlaying('/'))"> Is Playing?</A></P> <A HREF="javascript://" onmouseover="if (!mySoundObj1.IsPlaying()) mySoundObj2.TGotoAndPlay('/scale-event', 'start')"> Play A Scale</A></P> <SCRIPT> mySoundObj1.autostart = false; mySoundObj1.embedSWF("earsonly.swf"); mySoundObj2.embedSWF("scale.swf"); </SCRIPT> </BODY> </HTML>
Next: How to test if the player is ready
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: May 7, 2001
Revised: May 7, 2001
URL: https://www.webreference.com/js/column83/6.html