spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column83


Embedding Sound with Flash, Part III: Streams

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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 Scale

Here 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

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: May 7, 2001
Revised: May 7, 2001

URL: http://www.webreference.com/js/column83/6.html