如果客户端安装了 Windows Media Player 7,那么以下代码使得网页可以嵌入它。如果客户端尚未安装版本 7,但是它具有较早的版本,则会显示此版本
支持的版本:
- 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
以下是代码:
<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>