HTML Code for Embedding Windows Media Content (285154)



The information in this article applies to:

  • Microsoft Windows Media Services 4.0
  • Microsoft Windows Media Services 4.1
  • Microsoft Windows Media Player 6.4
  • Microsoft Windows Media Player 7
  • Microsoft Windows Media Player 7.1

This article was previously published under Q285154

SUMMARY

When you stream audio or video from a Windows Media server to a Windows Media Player client, you can embed the player in a Web page.

MORE INFORMATION

Use the following HTML code on a Web server to embed a Windows Media Player client:
<HTML>
<HEAD>
<TITLE>Document Title</TITLE>
</HEAD>

<BODY>

<script language="JavaScript">
<!--
    if ( navigator.appName == "Netscape" )
    {
        //-- This next line ensures that any plug-ins just installed are updated in the browser
        //-- without quitting the browser.
        navigator.plug-ins.refresh();
        // We don't need the APPLET within IE
        // ***Please note that if you do not need to script events, you can safely remove the next two lines
        document.write("\x3C" + "applet MAYSCRIPT Code=NPDS.npDSEvtObsProxy.class")
        document.writeln(" width=5 height=5 name=appObs\x3E \x3C/applet\x3E")
    }
//-->
</script>

<!-- Set ShowControls, ShowDisplay, ShowStatusBar to value 0 to not display the corresponding thing under the video window -->
<OBJECT ID="MediaPlayer" WIDTH=320 HEIGHT=240 classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"
standby="Loading Microsoft Windows Media Player components..."
type="application/x-oleobject">
    <PARAM NAME="FileName" VALUE="Station1.asx">
    <PARAM NAME="ShowControls" VALUE="1">
    <PARAM NAME="ShowDisplay" VALUE="1">
    <PARAM NAME="ShowStatusBar" VALUE="1">
    <PARAM NAME="AutoSize" VALUE="1">
    <Embed type="application/x-mplayer2"
        pluginspage="http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx/"
        filename="Station1.asx"
        src="Station1.asx"
        Name=MediaPlayer
        ShowControls=1
        ShowDisplay=1
        ShowStatusBar=1
        width=320
        height=240>
    </embed>
</OBJECT>

</BODY>
</HTML>
				
Usually, you also need to create a .asx metafile that contains connection and playlist information so that you can connect to a Windows Media server.

For more information about ASX metafiles and embedding the Windows Media Player, see the following Web page:

Modification Type:MinorLast Reviewed:5/30/2006
Keywords:kbinfo KB285154