seekTo method

Locates a specified point on the element's segment timeline, including repetitions, and begins playing from that point.

Syntax

*object.*seekTo(repeatCount, segmentTime)

Parameters

  • repeatCount [in]
    Type: LONG

    An Integer that specifies the repeatCount iteration at which to begin playing the element's timeline.

  • segmentTime [in]
    Type: double

    An Integer that specifies the point in the element's segment timeline at which to start playing the element. Legal values range from 0 to segmentDur.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

If you attempt to seek to a time on an object that is not currently active, an error is generated. To prevent this, check the object's status using the isActive property.

Not all media types support seeking. In cases where seeking is not supported by the player, calls to seek methods are ignored.

Examples

This example demonstrates how to use the seekTo property. Before validating and implementing the seekTo value, make sure the object is active, otherwise an error is generated. In this example, if the object is not active, the beginElement method is called to restart the object, followed by the seekTo method request.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/behaviors/seekTo.htm

<HTML xmlns:t= "urn:schemas-microsoft-com:time">
<HEAD>
<TITLE>seekTo Method</TITLE>

<?IMPORT namespace="t" implementation="#default#time2">
<STYLE>
    .time{behavior:url(#default#time2)}
</STYLE>
<SCRIPT>
function doSeek(){
        //Is media object active?
        //Yes, continue and do seek.
        //No, restart element using the beginElement method.
        if(!oMedia.currTimeState.isActive){
            oMedia.beginElement();
        }
        //Is user input valid and within the media's duration boundaries?
        if(isFinite(seekInput.value) && seekInput.value <= oMedia.mediaDur
            && seekInput.value > 0){
            oMedia.seekTo(1, seekInput.value);
        }else{
            //Input is not valid, alert user to re-enter choice.
            alert("Please enter a valid integer. Value must be greater than" +
                " 0 seconds and less than the media's duration (" + 
                oMedia.mediaDur + " seconds).");
            seekInput.focus();
        }
}
</SCRIPT>
</HEAD>

<BODY>        
<CENTER>
<B>Media timer:</B>
<SPAN id="Timer2" class="time" dur=".01" repeatCount="indefinite" fill="hold"
    onrepeat="innerText=parseInt(oMedia.currTimeState.activeTime);">0</SPAN>
<BR><BR>
<t:video style="width:175px; height:150px;" id="oMedia"
    src="/workshop/samples/author/behaviors/media/movie.avi"
    onmediacomplete="oMediaDur.innerText=oMedia.mediaDur;" />
<BR>
Media's duration: <SPAN id="oMediaDur"></SPAN>&nbsp;seconds
<BR><BR>
<B>Time value to seekTo in object's timeline</B>: 
    <INPUT type="text" value="" name="seekInput" size="3"/>&nbsp;seconds
<BR><BR>
<BUTTON id="seekBtn" onClick="doSeek();">Click to seek</BUTTON>&nbsp;
<BUTTON onClick="oMedia.beginElement()">Restart</BUTTON>

</CENTER>
</BODY>
</HTML>

See also

transitionFilter

animate

animateColor

animateMotion

animation

audio

excl

img

media

par

ref

seq

set

time2

video

Reference

seekActiveTime

seekSegmentTime

Conceptual

Introduction to HTML+TIME