Like this article? We recommend
Using Cue Points to Seek to a Specified Duration of a Video Clip
- Create a new Flash document called seekduration.fla.
- Drag an instance of the FLVPlayback component from the Components panel (Window > Components).
- The component is in the FLVPlayback - Player 8 folder.
- Select the component and open the Property inspector (Window > Properties > Properties).
- Type my_flvPb in the Instance Name text box.
- Drag an instance of the Button component from the Components panel to the Stage.
- Select the Button component and type seek_button in the Instance Name text box.
- Select Frame 1 on the Timeline and type the following code in the Actions
panel (see Figure 11).
import mx.controls.Button; import mx.video.FLVPlayback; var seek_button:Button; var my_flvPb:FLVPlayback; my_flvPb.autoPlay = false; my_flvPb.contentPath = "http://www.helpexamples.com/flash/video/sheep.flv"; seek_button.label = "Seek"; seek_button.addEventListener("click", seekFlv); function seekFlv(eventObj:Object):Void { // seek to 2 seconds my_flvPb.seek(2); }
- Select Control > Test Movie to test your code.
When you click the button, the video playhead moves to the duration that you specify; in this case, two seconds into the video (see Figure 11).
Figure 11 The linked movie playing in the SWF file. The Seek button has been pressed once and the video clip has skipped forward to the specified seek duration.