×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

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!

*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

Data Transmission general discussion FAQ

Streaming Media

How do I use Windows Media Player on my website? by tanderso
Posted: 23 Dec 00

You need to embed your player into the page using the <object> tag for IE and the <embed> tag for NS.  You can encapsulate the <embed> in the <object> so that IE only sees the <object> and NS only sees the <embed>.

eg:

<OBJECT
 ID="Video"
 WIDTH="320"
 HEIGHT="240"
 CODEBASE="http:// activex.microsoft.com/ activex/ controls/ mplayer/ en/ nsmp2inf.cab#Version=5,1,52,0701"
 CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
 STANDBY="Loading Windows Media Player components..."
 TYPE="application/x-oleobject">
   
 <PARAM NAME="FileName" VALUE="">
 <PARAM NAME="ShowControls" VALUE="0">
 <PARAM NAME="ShowStatusBar" VALUE="0">
 <PARAM NAME="ShowDisplay" VALUE="0">
 <PARAM NAME="AnimationAtStart" VALUE="1">
 <PARAM NAME="TransparentAtStart" VALUE="0">
 <PARAM NAME="AutoStart" VALUE="1">
 <PARAM NAME="AllowChangeDisplaySize" VALUE="1">
   
 <EMBED
  TYPE="application/x-mplayer2"
  PLUGINSPAGE="http:// www.microsoft.com/ Windows/ Downloads/ Contents/ Products/ MediaPlayer/"
  SRC=""
  NAME="Video"
  WIDTH="320"
  HEIGHT="240"
  ShowControls="0"
  ShowStatusBar="0"
  ShowDisplay="0"
  AnimationAtStart="1"
  TransparentAtStart="0"
  AutoStart="1"
  AllowChangeDisplaySize="1">
 </EMBED>
</OBJECT>

Ignore the spaces after the slashes in the URLs... they are only there so it would line break and not scroll all the way across the page.

Now, in order to access the plugin from JavaScript, it can be referenced as document.Video or, what I like to do is to name a simple variable:

var Player = document.Video;

To assign a file, you should do one of two things.  One, you could set the FileName and SRC attributes in the tags.  Two, you could set it via JavaScript:

if (IE) {Player.FileName = your_file;}
else {Player.SetFileName(your_file);}

This way you can set it dynamically by choosing amongst several files, for instance.  your_file can be any media type that WMP can play (mp3, wav, asf, wmf, etc).

In order to play the file, you should use:

Player.Play();

There are many other functions you can use, such as stop, fast forward, pause, rewind, etc.  There are also other attributes you can access such as the position, packets received, reception quality, etc.  Download the WMP SDK from http://www.microsoft.com for more info on that.

Back to Data Transmission general discussion FAQ Index
Back to Data Transmission general discussion 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