The method of embedding Media Player in a web page is relatively simple. You only need to use <Object> </Object> in HTML, as shown below.
<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">
</OBJECT>
The ID is the name of the object. When you want to control Media Player in JavaScript, you can use the name WMPlay to access the object. CODEBASE indicates that the Player control can be obtained from the specified location in the URL when the Player control is not installed in the browser.
You can also use <PARAM> to specify parameters when creating a Player object. As follows:
<Param name = "FileName" VALUE = "C: ASFRootWelcome. asf">
<Param name = "ShowControls" VALUE = "False">
<Param name = "AutoRewind" VALUE = "True">
<Param name = "AutoStart" VALUE = "False">
The "FileName" parameter indicates the live or stream of the file to be played by Media Player. "ShowControls" indicates whether the control bar is displayed during playback. Media Player has many parameters. We will not detail them here. For more details, see the relevant sections in the Media Player SDK.
You can use JavaScript to control Media Player.
In this example, Media Player is embedded in a Web page and has buttons on the right of Media Player. You can use these buttons to control the playback activity of Media Player. The HTML code for these buttons is as follows:
<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 = "StopClick ()">
</Form>
The corresponding JavaScript code is:
<Script language = "javascript">
<! --
Var g_Browser = navigator. appName;
Function controlType (setting)
{
If (g_Browser = "Netscape ")
Document. WMPlay. SetShowControls (setting );
Else
Document. WMPlay. ShowControls = setting;
}
<