speed property
Sets or gets the playback speed of an element relative to its parent time container.
Syntax
JScript |
---|
|
Property values
Type: Floating-point
the playback speed of an element relative to its parent time container.
Remarks
Element playback speed is relative to its parent time container at run time. For example, if the parent time container for an element and the element both have the speed property set to 0.5, the element plays back at 25 percent of its usual playback speed. That is, the parent plays at 50 percent, and the child plays at 50 percent of the parent speed, yielding a 25 percent playback speed for the child. You can obtain the runtime speed for an element by accessing the speed property exposed by the currTimeState object.
Negative values cause video elements to freeze on the last frame.
A value of zero is considered invalid. The media will play at the default of 1.0 if speed is set to 0
.
Some media players cannot play at the requested speed value. If the media player cannot keep up, an onoutofsync event occurs, and the requested speed value is treated as invalid. As a result, the media plays back at its usual speed. The rest of the timeline progresses at the specified speed value, even if the media player cannot keep up.
The speed value affects the length of the active duration of an element. If an object's speed is increased, the active duration is shorter than the value specified in the DUR attribute. If the object is slowed, the active duration is longer than the value specified in the DUR attribute.
Examples
This example shows how to use the speed property to set the playback speed of a timeline. The time container is set to begin at zero seconds, with a duration of five seconds and speed set to 0.5 (or one-half its usual speed). The child element is set to begin one second after its parent, with a duration of one second and speed set to 0.5 (one-half its usual speed). The parent speed of 0.5 multiplied by the child speed of 0.5 results in a speed of 0.25, or 25 percent. Therefore, the child element plays at 25 percent of its usual speed, or four times its duration, yielding a total duration of 4 seconds. The parent timeline plays at only 50 percent of its usual speed, or two times its duration, yielding a total duration of 10 seconds.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/behaviors/speed.htm
<HTML XMLNS:t="urn:schemas-microsoft-com:time">
<HEAD>
<?IMPORT namespace="t" implementation="#default#time2">
<STYLE>
.time{ behavior: url(#default#time2);}
</STYLE>
</HEAD>
<BODY>
<B>Document Timer:</B>
<SPAN id="Timer1" class="time" dur=".01" repeatCount="indefinite" fill="hold"
onrepeat="innerText=parseInt(document.body.currTimeState.activeTime);">0</SPAN>
<BR><BR>
<B>Time Container Timer:</B>
<SPAN id="Timer2" class="time" dur=".01" repeatCount="indefinite" fill="hold"
onrepeat="innerText=parseInt(t1.currTimeState.activeTime);">0</SPAN>
<BR><BR>
<t:excl ID="t1" begin="0; b1.onclick;" dur="5" speed="0.5">
<DIV ID="div1" CLASS="time" begin="1" DUR="1" speed="0.5"
style="color:blue;font-size:1in">Hello World!</DIV>
</t:excl>
<BR>
<BUTTON id="b1">Click to restart</BUTTON>
</BODY>
</HTML>