seekToFrame method
Locates a specified frame in the object.
Syntax
*object.*seekToFrame(frame)
Parameters
frame [in]
Type: longAn Integer that specifies a frame in the object.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
If you attempt to call the seekToFrame method 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 seekToFrame property. Before validating and implementing the seekToFrame value, make sure the object is active to avoid generating an error. In this example, if the object is not active, the beginElement method is called to restart the object, followed by the seekToFrame method call.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/behaviors/seekToFrame.htm
<HTML xmlns:t= "urn:schemas-microsoft-com:time">
<HEAD>
<?IMPORT namespace="t" implementation="#default#time2">
<STYLE>
.time{behavior:url(#default#time2)}
</STYLE>
<SCRIPT>
function doSeekToFrame(){
//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?
//Video has a total of 597 frames.
if(isFinite(seekFrame.value) && seekFrame.value >= 1 &&
seekFrame.value < 598){
oMedia.seekToFrame(seekFrame.value);
}else{
//Input is not valid, alert user to re-enter choice.
alert("Please enter a valid integer. Possible values are 1 to" +
" 597 inclusive.");
seekFrame.value = "";
seekFrame.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:175; height:150;" id="oMedia"
src="/workshop/samples/author/behaviors/media/movie.avi"/>
<BR>
Current frame: <SPAN id="oCurrFrame" class="time" dur="0.01"
repeatCount="indefinite" fill="hold"
onrepeat="innerText=parseInt(oMedia.currentFrame);"></SPAN>
<BR><BR>
<B>Frame to seek to</B>:
<INPUT type="text" value="" name="seekFrame" size="3"/> seconds
<BR><BR>
<BUTTON id="seekBtn" onClick="doSeekToFrame();">Click to seek</BUTTON>
<BUTTON onClick="oMedia.beginElement()">Restart</BUTTON>
</CENTER>
</BODY>
</HTML>
See also
Reference
Conceptual