re: Media Player embedding issue

From: Jim Buyens (news_at_interlacken.com)
Date: 06/26/04


Date: Sat, 26 Jun 2004 09:07:36 -0700

I spent some time playing with this and couldn't find a
really satisfying solution. The following code *sort of*
works (if all on one line, and if player is the name of
the Media Player object):

<a href="javascript:;"
onclick="player.URL='sounds/dog.wav';player.controls.play
();">Play</a>

but even though the sound plays, I get an error message
stating that the play method isn't available. There's a
fix for that error message -- I could change some
security settings and then rerun Media Player setup, but
how many Web visitors are going to discover the same
problem, find the fix, and then apply it, just for your
Web site?

If you have Frontpage 2003, a much better solution is to
forget Media Player, and just use the Play Sound
behavior. To do this, you select the text that will
trigger the sound, display the Behaviors task pane, click
Insert, choose Play Sound, and specify the sound file you
want.

If you have FP2002 or earlier, paste this script into the
<head> section of your page:

<script language="JavaScript">
<!--
function playIt(path) {
  var b,e,es,i
  var d=document
  var se="<EMBED SRC='"+path+"' HIDDEN=TRUE LOOP=FALSE
AUTOSTART=TRUE>";
  if(d.body) b=d.body;
  if(d.getElementsByTagName) {
    es=d.getElementsByTagName('embed')
    for(i=0;i<es.length;i++) {
      e=es(i);
      if( e.src==path ) {
        if(e.removeNode) e.removeNode();
          break;
        }
      }
    if(b&&b.insertAdjacentHTML) b.insertAdjacentHTML
("beforeend",se);
  }
}
// -->
</script>

and then code your hyperlink:

href="javascript:playIt(sounds/DOG.WAV')"

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------

>-----Original Message-----
>I know how to embed media player. Is there a way to
embed media player and
>have it called by a link on the page? Example at one of
my websites in
>developement:
>
>http://renaraso.com/yoga.htm
>
>My links work for asana, vinyasa and pranayama, but i
would like to embed 3
>media players (invisible mode) and have those 3 links
call their respective
>media player to play the wav file seamlessly, that is,
with no interuption
>of a media player loading on the viewer's pc. I've tried
and tried, but
>can't seem to put this together.
>
>Tom
>
>
>.
>