April 30, 2001 - Checking if Flash is Playing
April 30, 2001 Checking if Flash is Playing Tips: April 2001
Yehuda Shiran, Ph.D.
|
IsPlaying()
method. The IsPlaying()
method has no arguments and it returns true
if the playhead is moving, false
otherwise.
As a reminder, in order to sonify your page, follow this recipe:
flashsound.js
in the HEAD
section. Download.
HEAD
section.
BODY
section.
onmouseover
event handler to the TGotoAndPlay()
method.
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?". Notice that indeed the answer is true
when the track plays, false
otherwise. Go ahead and mouse over the links. Check if the playhead is moving, before you mouse over the left link. Mouse over the left link to start it, and then check again:
Rewind and Play Pause Continue Is Playing?
Here is the source code:
<HTML>
<HEAD>
<SCRIPT SRC="flashsound.js"></SCRIPT>
<SCRIPT>
var mySoundObj = new FlashSound();
</SCRIPT>
</HEAD>
<BODY>
<A HREF="javascript://"
onmouseover="mySoundObj.TGotoAndPlay('/',1)">Rewind and Play</A>
<A HREF="javascript://"
onmouseover="mySoundObj.TStopPlay('/')">Pause</A>
<A HREF="javascript://"
onmouseover="mySoundObj.TPlay('/')">Continue</A>
<A HREF="javascript://"
onmouseover="alert(mySoundObj.IsPlaying('/'))">Is Playing?</A>
<SCRIPT>
mySoundObj.autostart = false;
mySoundObj.embedSWF("earsonly.swf");
</SCRIPT>
</BODY>
</HTML>
Notice we assign autostart to false
. The reason is that the stream example here was set to autostart upon embedding. We can override the Flash behavior with JavaScript commands.
Here are links you can use to download flashsound.js
and earsonly.swf
: