Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here



Streaming Media

Using Windows Media Player with 1 control button to stop and play by soonkhoo
Posted: 28 Dec 00

This code was helped by a few people and special thanks to Ben a.k.a Bangers for creating image swapping code. This discussion could be found at Thread215-43476.

Basically, you have the embeded WMP and is controlled with only 1 button. When click on the Stop button, the image will swap to a Play button and the Audio will stop. Vice versa.

If you use this code, do make sure you set the correct files for your audio. It supports all kinds. If you want to see the WMP default controls on your site. Go to the <object> tag and set showcontrols to true. And if you don't want to autostart when entering your site. Set to false at the param. Do what ever you want. It works.

I had hidden the WMP. So if you want to see it...change the width and height greater than zero at the object tag.

<HEAD><TITLE>Windows Media Player Test</TITLE>

<script language="JavaScript">
      var myImageOn = new Image();
      myImageOn.src = 'Images/play.gif';
    function imageSwap(){
            document.mybutton.isOff = false;
            document.mybutton.src = myImageOn.src;
            document.mybutton.name = "BtnStop";
    MediaPlayer1.CurrentPosition = 0;
        else if(!document.mybutton.isOff)
            document.mybutton.isOff = true;
            document.mybutton.name = "BtnPlay";
<BODY bgcolor="#EEEEEE">

<object id="MediaPlayer1" width=0 height=0
  standby="Loading Microsoft« Windows MediaĂ– Player components..."
  type="application/x-oleobject" align="middle">
  <param name="FileName" value="C:\My Music\UB40 - Red Red Wine.mp3">
  <param name="ShowControls" value="False">
  <param name="AutoRewind" value="True">
  <param name="AutoStart" value="True">
  <embed name="MediaPlayer1" width="27" height="17" filename="C:\My Music\UB40 - Red Red Wine.mp3" showcontrols="False" autorewind="True" autostart="True" src="C:\My Music\UB40 - Red Red Wine.mp3" align="middle">
</object> <a href="javascript:imageSwap()"><img border="0" name="BtnStop" id="mybutton" isOff=true src="Images/stop-up.gif" width="27" height="23"></a>


Back to HTML, XHTML & CSS FAQ Index
Back to HTML, XHTML & CSS Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close