Control the start point and play length of a media stream on the page
Source: Internet
Author: User
Recently, in a web project, the customer proposes to input the start time and end time in the audio file for audition, and then play the video from the start time to the end time. After searching several times in google, no relevant documents can be found, and you only need to conduct research on your own.
At the beginning, I focused on the attributes of the Media Player control and found the following attributes:
CurrentPosition returns or sets the current position of the clip (double precision ).
Duration returns or sets the playback time (dual-precision) of the video clip ).
SelectionEnd returns or sets the end position of the stream (double precision type ).
SelectionStart returns or sets the starting position of the stream (double precision type ).
After testing, you can implement the required functions by controlling the CurrentPosition attribute. The other three attributes do not have any effect. However, when the page is placed on a remote server, it is found that this function does not work. When the buffer has not reached the start time, it cannot jump.
Later, I had to study Windows Media Player 9 Series SDK and found that STARTTIME and DURATION Elements in Windows Media Metafile Elements Reference are exactly what I needed. To use these two elements, you must use them in the asx file.
The asx file format is as follows:
<Asx version = "3.0">
<TITLE> Your title here </TITLE>
<ENTRY>
<Ref href = "audio file access path"/>
<Starttime value = "0: 30. 0"/>
<Duration value = "00:50"/>
</ENTRY>
</ASX>
After multiple tests, the solution is feasible. Now the problem is simple. That is, let the user generate the asx file after the submission start time and end time, and then send the file to media player.
The following is my access interface:
However, during the test, it was found that the file was transferred, but media player could not play the video. It was strange. The test shows that it is okay to directly use the local media player to play the video. The problem must be caused by the media player attribute on the page. I reduced the parameter of media player to only one filename attribute, and found that the parameter is OK. Then set the autostart attribute to false, and you will find that it cannot work. Finally, you have to set the autostart attribute to true.
The final player's attributes are set as follows:
<Param name = "AutoStart" value = "true">
<Param name = "Filename" value = "">
<Param name = "ShowPositionControls" value = "true">
<Param name = "ShowStatusBar" value = "true">
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.