Share via


Simple Windows Media Player Control Web Page

Windows Media Player SDK banner art

By combining the elements previously discussed in this article, you can see how the pieces fit together in the following sample code.

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

<OBJECT ID="MediaPlayer1" WIDTH=320 HEIGHT=240
  CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"
  STANDBY="Loading Windows Media Player components..."
  TYPE="application/x-oleobject">

  <PARAM NAME="FileName" VALUE="C:\ASFRoot\Welcome.asf">
  <PARAM NAME="ShowControls" VALUE="False">
  <PARAM NAME="AutoRewind" VALUE="True">
  <PARAM NAME="AutoStart" VALUE="False">
</OBJECT>

<BR>
<INPUT TYPE="BUTTON" NAME="BtnPlay" VALUE="Play">
<INPUT TYPE="BUTTON" NAME="BtnStop" VALUE="Stop">
<INPUT TYPE="BUTTON" NAME="BtnAbout" VALUE="About">

<SCRIPT LANGUAGE="VBScript">
<!--
Sub BtnAbout_OnClick
   MediaPlayer1.AboutBox
End Sub

Sub BtnPlay_OnClick
    MediaPlayer1.Play
End Sub

Sub BtnStop_OnClick
    MediaPlayer1.Stop
    MediaPlayer1.CurrentPosition = 0
End Sub
-->
</SCRIPT>

</BODY>
</HTML>

Try this code with a multimedia file on your computer. Copy and paste the code into a text file, and change the value of the FileName attribute to specify the protocol, relative path, and name of the clip you want to play.