Use Media Player on Web pages

Source: Internet
Author: User

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;
}

<
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.