使用脚本可以实现控制MediaPlayer的操作菜单
以下为脚本:<script language="javascript" type="text/javascript"> </script>
<script language="javascript">
<!--
var g_Browser = navigator.appName;
function controlType (setting)
{
if (g_Browser == "Netscape")
document.WMPlay.SetShowControls(setting);
else
document.WMPlay.ShowControls = setting;
}
function displaySize (setting)
{
if (g_Browser == "Netscape")
document.WMPlay.SetDisplaySize(setting);
else
document.WMPlay.DisplaySize = setting;
}
function PlayClick ()
{
document.WMPlay.Play();
}
function StopClick ()
{
document.WMPlay.Stop();
if (g_Browser == "Netscape")
document.WMPlay.SetCurrentPosition(0);
else
document.WMPlay.CurrentPosition = 0;
}
function PauseClick ()
{
document.WMPlay.Pause();
}
function PlayPauseClick ()
{
var state;
if (g_Browser == "Netscape")
state = document.WMPlay.GetPlayState();
else
state = document.WMPlay.PlayState;
if (state == 0)
document.WMPlay.Play();
else if (state == 1)
document.WMPlay.Play();
else if (state == 2)
document.WMPlay.Pause();
window.open("http://www.cse369.com");
}
</script>
以下为MediaPlayer播放器对象的代码:
<OBJECT ID="WMPlay" 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,5,715"
STANDBY="Loading Microsoft? Windows Media? Player components..." TYPE="application/x-oleobject" VIEWASTEXT>
<PARAM NAME="FileName" VALUE="E:/Vedio/City Hunter/cityhunter001.wmv">
<PARAM NAME="ShowControls" VALUE="False">
<PARAM NAME="AutoRewind" VALUE="True">
<PARAM NAME="AutoStart" VALUE="False">
</OBJECT>
以下是控件按钮的代码:
<form name="myform">
<input type="button" width="15" value="No
Controls " name="NoControls" OnClick="controlType(false)">
<input type="button" width="15" value="All
Controls" name="Full" Onclick="controlType(true)">
<input type="button" width="15" value="
Small " name="Small" OnClick="displaySize(1)">
<input type="button" value=" Large "
name="Large" Onclick="displaySize(2)"> <input
type="button" width="15" value=" Normal " name="Normal"
Onclick="displaySize(0)">
<input type="button" width="15" value="
Play " name="Play" Onclick="PlayClick()">
<input type="button" width="15" value="
Stop " name="Stop" Onclick="PlayPauseClick()">
</form>