Common web player code-WMP

Source: Internet
Author: User
Tags return tag
<Object ID = "Player" Height = "64" width = "260" classid = "CLSID: 6bf52a52-394a-11d3-b153-00c04f79faa6">
<Param name = "autostart" value = "-1">
<! -- Automatic playback? -->
<Param name = "balance" value = "0">
<! -- Adjust the left-right channel balance and the old player code above -->
<Param name = "enabled" value = "-1">
<! -- Whether the player can be controlled by humans -->
<Param name = "enablecontextmenu" value = "-1">
<! -- Enable context menu -->
<Param name = "url" value = "/blog/1.wma">
<! -- Playback file address -->
<Param name = "playcount" value = "1">
<! -- Control the number of playbacks, which is an integer -->
<Param name = "rate" value = "1">
<! -- The playback speed is controlled. 1 is normal, and decimal places are allowed. -->
<Param name = "currentposition" value = "0">
<! -- Control settings: Current Position -->
<Param name = "currentmarker" value = "0">
<! -- Control settings: Current tag -->
<Param name = "defaultframe" value = "">
<! -- Display default frame -->
<Param name = "invokeurls" value = "0">
<! -- Script command setting: whether to call URL -->
<Param name = "baseurl" value = "">
<! -- Script command setting: called URL -->
<Param name = "stretchtofit" value = "0">
<! -- Scale up or not -->
<Param name = "volume" value = "50">
<! -- The default sound size is 0%-100%, and 50 is 50%. -->
<Param name = "mute" value = "0">
<! -- Mute or not -->
<Param name = "uimode" value = "mini">
<! -- Player display mode: full display all; Mini is the most simplified; none does not show the playback control, only the video window is displayed; invisible does not show all -->
<Param name = "windowlessvideo" value = "0">
<! -- If it is 0, full screen is allowed; otherwise, it can only be viewed in the window -->
<Param name = "fullscreen" value = "0">
<! -- Whether to enable automatic full screen playback -->
<Param name = "enableerrordialogs" value = "-1">
<! -- Enable error prompt report -->
<Param name = "samistyle" value>
<! -- Sami style -->
<Param name = "samilang" value>
<! -- Sami language -->
<Param name = "samifilename" value>
<! -- Subtitle id -->
</Object>

 

 

 

Guide to WMP video control on Web pages

□Playback method and attributes
In addition to playing, pausing, and stopping, the media player can also use the following attributes:
Scan-similar to the fast forward and backward functions of a video recorder;
Search (seeking) -- directly move to the specific stage time marked in the clip;

□Playback
The Media Player provides two techniques to specify the media name (CLIP) to be played. You can set the filename attribute or call the open method. If the value of the autostart attribute is true, after the filename attribute is set to the URL of the video clip, the video clip starts to play; otherwise, the video clip does not start to play, unless you call the play method. The open method starts playing asynchronously. It is not like the play method that starts playing after other processes are completed.
The Media Player provides the following attributes and methods similar to those of a video recorder to control streaming media playback:
Play, stop, and pause methods to start, stop, and pause streaming media.
Playcount attribute to set the number of playback times of a file.
Autorewind attribute to determine whether to return to the start part of the video clip when the playback is stopped.

□Audio Control
Media Player provides the following attributes to manage audio:
Balance attribute to determine the sound balance between the left and right speakers;
Volume attribute, used to increase or decrease the volume;
The mute attribute, which is used to disable or enable sound;
※You can set the showaudiocontrols attribute to true to add a sound processing control in the control bar.

□Scan
Media Player provides the following attributes for scanning:
Fastforward method, fast forward;
Fastreverse method, fast down;
Rate attribute to change the playback speed;
※To enable film editing to be scanned, set the canscan and allowscan attributes to true.

□Search
The following attributes are used for search:
The markercount attribute indicates the total number of tags in a clip;
Currentmaker, getmarkername, and getmarkertime are used to return tag information;
Markerhit event, triggered when a tag is encountered;
Currentposition attribute, current position (measured in seconds), which can be used to move the playback header to the point specified in the clip;
Positionchange event, triggered when the currentposition attribute is set;
※To search for any time, set the canseek attribute to true. To search for a tag, set the canseektomarkers attribute to true.

□Media player appearance Interface
On the webpage, you can use relevant attributes to control which parts of the Media Player appear and which parts do not appear.
Media players include the following elements:
Video Display Panel: the video display panel;
Video border: Video border;
Closed captioning display panel; subtitle display panel;
Track bar; search bar;
Control bar with audio and position controls: control bar with sound and Position Control;
Go to bar: Go to the bar;
Display Panel: Display Panel;
Status Bar: status bar;
The following attributes are used to determine which element to display:
Showcontrols attribute: whether to display the control bar (including the playback control and optional sound and position control );
Showaudiocontrols properties: whether to display the sound control (mute button and volume slider) in the control bar );
Showpositioncontrols attribute: whether to display the Position Control in the control bar (including Backward Jump, fast back, fast forward, forward jump, preview each clip in the playback list );
Showtracker property: whether to display the search bar;
Showdisplay attribute: whether to display the display panel (used to provide program and clip information );
Showcaptioning attribute: whether to display the subtitle display panel;
Showgotobar attribute: whether to show and go to the bar;
Showstatusbar attribute: whether to display the status bar;

□Playlist
The Media Player provides the following methods to access the clips in the playlist:
Next method, jump to the next clip in the Program (playlist;
The previous method jumps back to the previous clip in the program;
One feature of a Media Player is to preview every clip in a program using the following attributes:
The previewmode attribute determines whether the media player is in preview mode;
The canpreview attribute determines whether the media player is in preview mode;
In the Windows Media element file, you can specify the preview time-previewduration for each clip. If not, the default preview time is 10 seconds.
You can also use the Windows Media meta file to add watermarks and banners. The Meta File also supports non-gap stream switching when inserting advertisements.

□Program Information
You can use the getmediainfostring method to return the following information about related clips or programs:
File Name: File Name
Title: Title
Description: Description
Author: Author
Copyright: Copyright
Level: Rating
URLs: logo icon, watermark, banner address
Editing information can be stored in a media file, a Windows Media meta file, or both. If the clip information is specified in the Metafile, the information in the Metafile is returned using the getmediainfostring method, instead of the information contained in the clip.
In the Metafile, additional information can be placed in the param tag of each clip or program. You can add any number of param tags for each clip to store custom information or link to related sites. The information in the param tag can be accessed using the getmediaparameter method.
The following attributes return information about the size and time:
Imagesourceheight and imagesourcewidth: return the display size of the image window;
Duration Attribute. The length of the clip (in seconds) is returned. to check whether this attribute contains valid values, check the isdurationvalid attribute. (The length of a broadcast video is unpredictable ).

□Subtitle
You can use the. SMI file to add subtitles for your program. Media players support the following attributes to process Subtitles:
Samifilename attribute, specifying the name of the. SMI file;
Samilang attribute, specify the subtitle language (if not specified, use the first language );
Specifies the subtitle text size and style;
The showcaptioning attribute determines whether to display the subtitle display panel;

□Script command
With audio and video streams, you can add script commands to streaming media files. The script command is a multi-to-Unicode string that Synchronizes time with a specific time in a multimedia stream. The first string identifies the type of the command to be issued, and the second string specifies the command to be executed.
When streaming is placed at a script-related time, the control will send a scriptcommand event to the webpage, and then the event processing process will respond to the event. The script command string is passed to the event processor as a parameter of the script command event.
The Media Player automatically processes the following types of embedded script commands:
1) URL-based command: when the media player control receives a URL-based Command, the specified URL will be loaded to your default browser. If the media player is embedded in an HTML file with frame separation, the URL page can be loaded into the frame specified by the script command. If the script command does not specify a frame, the defaultframe attribute determines which frame the URL page is loaded.
You can set the invokeurls attribute to determine whether to automatically process URL-type script commands. If the value of this attribute is false, the Media Player control ignores URL commands. However, the script command event will still be triggered, which allows you to selectively process URL-type commands.
The URL Command specifies the relative address of the URL. The base address is specified by the baseurl attribute. The command parameter of the script command event sent by the Media Player control is the link address.
2) filename command: when the media player control receives a filename command, it sets the filename attribute to the file provided by the script command, and then the Media Player starts playing the file. Media Player controls always process filename commands automatically. Unlike URL commands, they cannot be disabled.
3) text command: when the media player control receives a text command, it displays the command content in the control's subtitle window. The content can be plain text or HTML.
4) Event-Type COMMAND: when the media player control receives an event-type command, it searches for the name attribute of the event element in the media element file. If the name attribute matches the second string in the script command, the Media Player control executes the entries contained in the event element.
5) openevent-Type COMMAND: when the media player control receives an openevent-type command, it checks the event element in the media element file and opens the matched title, but does not play the video, wait until you receive the real event with the same name from the event command.

□Capture keyboard and mouse events
The enablecontextmenu and clicktoplay attributes provide users with methods to operate in the image window.
If the enablecontextmenu attribute is true, right-click the image window to open the association menu. If the clicktoplay attribute is set to true, you can click the image window to switch between playing and pausing.
To receive mouse movement and click events, set the sendmousemoveevents and sendmouseclickevents attributes to true. Mouse events include:
Mousedown, which is generated when you press the mouse;
Mouseup, generated when the user releases the mouse;
Mousemove, generated when the user moves the mouse;
Click, which is generated when you click the mouse button on the media player;
Dbclick, which is generated when you double-click the mouse button on the media player;
To receive Keyboard Events, set the sendkeyboardevents attribute to true. Keyboard Events include:
Keydown, generated when the user presses the next key;
Keyup, generated when the user releases a key;
Keypress, generated when the user presses and releases a key;

□Monitoring stream status and network connection
Flow status attributes include:
Playstate: playback status;
Openstate: open;
Bandwidth: bandwidth;
Supported events include:
Openstatechange: changes the open status (triggered only when the sendopenstatechangeevents attribute is true)
Playstatechange: changes the playback status (triggered only when the sendplaystatechangeevents attribute is true)
Endofstream: triggered when the stream ends;
Newstream: triggered when a new stream is opened;
Network receiving attributes include:
Predictionquality: receiving quality;
Receivedpackets: received packages;
Lostpackets: The Lost package;
Monitoring buffer attributes include:
Bufferingtime: buffer time;
Bufferingcount: Buffer count;
Bufferingprogress: Buffer process;
Buffering: buffering events;

□Error handling
Media Player provides the built-in error handling function-displaying error messages in the dialog box or status bar. In addition, you can add an error handler by yourself. If the senderrorevents attribute is set to true, the error box is not displayed, but an error event is sent. If the senderrorevents attribute is set to false, the error box is displayed, but an error event is sent.
Media Player supports the following error handling events:
An error occurs when a dangerous error occurs;
A warning event indicates a non-dangerous error;
When your application receives an error event, you can check the following attributes to determine the specific error message:
Haserror: checks whether the current media player has an error;
Errorcode: Provides the code value related to this type of error;
Errordescription: Provide the error description;
Errorcorrection: Specifies the media player to correct errors of this type;

□Play CD
Media players regard CD as a single audio stream (marked at the beginning of each audio track. To use CD in a webpage, you must set the filename attribute to cdaudio:, which must contain a colon, as shown below:
<HTML>
<Head> <title> Cd audio playback example </title> <Body>
<Object ID = "mediaplayer"
Classid = "CLSID: 22d6f312-b0f6-11d0-94ab-0080c74c7e95"
Width = "320"
Height = "508"
Style = "position: absolute; left: 0px; top: 70px;">
<Param name = "FILENAME" value = "cdaudio:">
<Param name = "autostart" value = "0">
<Param name = "showcontrols" value = "1">
<Param name = "showstatusbar" value = "1">
<Param name = "showdisplay" value = "1">
</Object>
</Body>

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.