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.
As a reminder, in order to sonify your page, follow this recipe:
- Make sure you have the Flash player. 96% of the surfing population already has it. Download.
- Include
flashsound.js in the HEAD section. Download.
Create a flashsound object in the HEAD section.
Embed your SWF file in the BODY section.
Create an anchor tag and set the 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:
Download flashsound.js
Download earsonly.swf
People who read this tip also read these tips:
Look for similar tips by subject:
|