Microsoft KB Archive/279022

From BetaArchive Wiki
Knowledge Base


Auto embedding Windows Media Player 7 in Web page if it is installed on the client

Article ID: 279022

Article Last Modified on 11/19/2007



APPLIES TO

  • Microsoft Windows Media Player 6.0
  • Microsoft Windows Media Player 6.1
  • Microsoft Windows Media Player 6.2
  • Microsoft Windows Media Player 6.4
  • Microsoft Windows Media Player 7.0
  • Microsoft Windows Media Player 7.1



This article was previously published under Q279022

SUMMARY

When you embed a Windows Media Player client into a Web page, you can use client-side code to detect whether version 7 or later is installed. In doing so, you can take advantage of version 7 or later features if that version is installed.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
The following code enables your Web page to embed Windows Media Player 7 if the client has it installed. If the client does not have version 7 installed, but it does have an earlier version, that version will be displayed instead.

<html>
<head>
<title>Embedding Windows Media Player</title>
</head>
<body>


<!-- Check Media Player Version -->

<SCRIPT LANGUAGE="VBScript">
<!--
On Error Resume Next
lngMP70 = IsObject(CreateObject("WMPlayer.OCX"))

' Windows Media Player 7 Code
If (lngMP70) Then
    document.write "<OBJECT ID=MediaPlayer "
    document.write " CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6"
    document.write " standby=""Loading Microsoft Windows Media Player components..."" "
    document.write " TYPE=""application/x-oleobject"" width=""286"" height=""225"">"
    document.write "<PARAM NAME=""url"" VALUE=""http://ncnetshow/station1.asx"">"
    document.write "<PARAM NAME=""AutoStart"" VALUE=""true"">"
    document.write "<PARAM NAME=""ShowControls"" VALUE=""1"">"
    document.write "<PARAM NAME=""uiMode"" VALUE=""mini"">"
    document.write "</OBJECT>"

' Windows Media Player 6.4 Code
Else
    document.write "<OBJECT ID=MediaPlayer "
    document.write " CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
    document.write "CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
    document.write " standby=""Loading Microsoft Windows Media Player components..."" "
    document.write " TYPE=""application/x-oleobject"" width=""286"" height=""225"">"
    document.write "<PARAM NAME=""FileName"" VALUE=""http://ncnetshow/station1.asx"">"
    document.write "<PARAM NAME=""AutoStart"" VALUE=""true"">"
    document.write "<PARAM NAME=""ShowControls"" VALUE=""1"">"
    document.write "</OBJECT>"
End If

-->
</SCRIPT>

</body>
                



Here is the same code, but in JavaScript form:

<html>
<head>
<title>Embedding Windows Media Player</title>
</head>
<body>

<!-- Check Media Player Version -->

<SCRIPT LANGUAGE="JavaScript">

var WMP7;

if(window.ActiveXObject)
{
    WMP7 = new ActiveXObject("WMPlayer.OCX.7");
}
else if (window.GeckoActiveXObject)
{
     WMP7 = new GeckoActiveXObject("WMPlayer.OCX.7");
}

// Windows Media Player 7 Code
if ( WMP7 )
{
     document.write ('<OBJECT ID=MediaPlayer ');
     document.write (' CLASSID=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6');
     document.write (' standby="Loading Microsoft Windows Media Player components..."');
     document.write (' TYPE="application/x-oleobject" width="286" height="225">');
     document.write ('<PARAM NAME="url" VALUE="http://ncnetshow/station1.asx">');
     document.write ('<PARAM NAME="AutoStart" VALUE="true">');
     document.write ('<PARAM NAME="ShowControls" VALUE="1">');
     document.write ('<PARAM NAME="uiMode" VALUE="mini">');
     document.write ('</OBJECT>');
}

// Windows Media Player 6.4 Code
else
{
     //IE Code
     document.write ('<OBJECT ID=MediaPlayer ');
     document.write ('CLASSID=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 ');
     document.write ('CODEBASE=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715 ');
     document.write ('standby="Loading Microsoft Windows Media Player components..." ');
     document.write ('TYPE="application/x-oleobject" width="286" height="225">');
     document.write ('<PARAM NAME="FileName" VALUE="http://ncnetshow/station1.asx">');
     document.write ('<PARAM NAME="AutoStart" VALUE="true">');
     document.write ('<PARAM NAME="ShowControls" VALUE="1">');

     //Netscape code
     document.write ('    <Embed type="application/x-mplayer2"');
     document.write ('        pluginspage="http://www.microsoft.com/windows/windowsmedia/"');
     document.write ('        filename="http://ncnetshow/station1.asx"');
     document.write ('        src="http://ncnetshow/station1.asx"');
     document.write ('        Name=MediaPlayer');
     document.write ('        ShowControls=1');
     document.write ('        ShowDisplay=1');
     document.write ('        ShowStatusBar=1');
     document.write ('        width=290');
     document.write ('        height=320>');
     document.write ('    </embed>');

     document.write ('</OBJECT>');
}

</SCRIPT>

</body>
</html>
                


Additional query words: netshow wmplayer

Keywords: kbproductlink kbcode kbinfo KB279022