Windows Media Player webpage player and Its Parameter meanings

Source: Internet
Author: User
Tags first string return tag

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;

 

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

 

-- Monitor the 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;

 

-- Handle errors
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 cdaudi with a colon as follows:
<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 = "cdaudi">
<Param name = "autostart" value = "0">
<Param name = "showcontrols" value = "1">
<Param name = "showstatusbar" value = "1">
<Param name = "showdisplay" value = "1">
</Object>
</Body>
</Html>
Then you can use the play method to play the CD.
You can specify the playing sequence and information of each audio track in the Windows Media element file. Example:

<ASX version = "3.0">
<Title> Cd audio with the Media Player </title>
<Author> Windows Media Technologies </author>
<Copyright> (c) 1999, Microsoft, Inc. </Copyright>

<Entry>
<Title> track 1: Title 1 </title>
<Ref href = "/blog/cdaudi"/>
<Startmarker number = "1"/>
<Endmarker number = "2"/>
</Entry>

<Entry>
<Title> Track 2: Title 2 </title>
<Ref href = "/blog/cdaudi"/>
<Startmarker number = "2"/>
<Endmarker number = "3"/>
</Entry>

<Entry>
<Title> track 3: Title 3 </title>
<Ref href = "/blog/cdaudi"/>
<Startmarker number = "3"/>
<Endmarker number = "4"/>
</Entry>

<Entry>
<Title> track 4: Title 4 </title>
<Ref href = "/blog/cdaudi"/>
<Startmarker number = "4"/>
</Entry>
</ASX>

 

Appendix:

1. How to paste RM, Ra, Ram music, the Code is as follows:
<Embed width = "0" Height = "0" type = "audio/X-PN-RealAudio-plugin" autostart = "true" controls = "controlpanel" src = "http://guest.anyp.cn/uploads/01.rm" ;>

 

2. How to paste the Midi, ASF, WMA, and ASX types of music, the Code is as follows:
<Embed autostart = "true" loop = "-1" controls = "controlpanel" width = "0" Height = "0" src = "http://guest.anyp.cn/uploads/01.mid";>

 

3. <bgsound src = "your song address" loop = "-1">

You only need to copy the entire code segment to the Article (use the HTML code mode when editing the article; otherwise, the code segment will be displayed in text format and cannot be executed ), replace the above music address code with the URL of your favorite music file. Note: If the browsing speed is greatly affected by music, the browser may stop responding. Therefore, do not use large files if you want to play background music.

The URL of a music file refers to the URL of the music file.
To obtain the URL, right-click the connected music name and choose Copy shortcut, then press Ctrl + C to add the URL of the music file (paste the copied address ).

Two errors may occur when the background music cannot be listened to normally:
1. The music address is incorrect. The URL Ending with HTML is treated as the music address by mistake.
2. The music file is too large and takes a long time to play.

<Embed Height = 26 src = http://song.5music.org/5musicreall/2003_ydzh/emhj/1-14.rm type = audio/X-PN-RealAudio-plugin width = 120 controls = "statusfield" autostart = "true"
Add music code. This Code adds music in RM format. We recommend that you use this code, which is faster.
<Bgsound src = '??? & Apos; loop = true & apos. We recommend that you replace the question mark with the music address when using this code. True can be changed to Arabic numerals. Used to control the number of times the music is played.
<Embed src = ?? Width = 240 hight = 180> This code inserts a flash image. Adjust the image size in the numeric part.
<Script language = "JavaScript" src = "http://danlovesary.y365.com/music/music.js"> </SCRIPT>

Common Properties and methods of the windowsmediaplayer Control

The windowsmediaplayer control is often used in programming, but many attributes and methods do not know how to use it. The following uses the WMP 9.0 control as an example to describe its common attributes and methods in Delphi 7.0 (the usage in Javascript is almost identical ).

Assume that the control is named WMP.

Attribute/method name: Description:
[Basic attributes]
URL: string; specifies the media location, local or network address
Uimode: string; player interface mode, which can be full, Mini, none, invisible
Playstate: integer; playback status, 1 = stopped, 2 = paused, 3 = played, 6 = buffering, 9 = connected, 10 = ready
Enablecontextmenu: Boolean; enable/disable context menu
Fullscreen: Boolean; Whether to display in full screen
[Controls] WMP. Controls // basic player control
Controls. Play; play
Controls. Pause; pause
Controls. Stop; stop
Controls. currentposition: Double; current progress
Controls. currentpositionstring: string; current progress, string format. For example"
Controls. fastforward; Fast Forward
Controls. fastreverse; fast return
Controls. Next; next
Controls. Previous; previous Curve
[Settings] WMP. settings // basic player settings
Settings. Volume: integer; volume: 0-100
Settings. autostart: Boolean; Whether to play automatically
Settings. Mute: Boolean; mute
Settings. playcount: integer; number of playbacks
[Currentmedia] WMP. currentmedia // current media attribute
Currentmedia. Duration: Double; total media Length
Currentmedia. durationstring: string; total media length, in string format. For example"
Currentmedia. getiteminfo (const string); get current media information "title" = media title, "author" = artist, "Copyright" = copyright information, "Description" = media content description, "duration" = duration (seconds), "filesize" = file size, "filetype" = file type, "sourceurl" = original address
Currentmedia. setiteminfo (const string); set media information by attribute name
Currentmedia. Name: string; same as currentmedia. getiteminfo ("title ")
[Currentplaylist] WMP. currentplaylist // attributes of the current playlist
Currentplaylist. Count: integer; number of media contained in the current playlist
Currentplaylist. item [integer]; gets or sets the media information of the specified project. Its subattributes are the same as that of WMP. currentmedia.

For more information, see the Windows Media Player 9 SDK documentation.

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.