618 Working with Images, Sound, and Video
Alternatively, you can also seek to a specified duration of the FLV file, using the
seek() method.
In the following examples, you add a button that you use to jump between cue points or a
specified duration in a FLV file that plays in the FLVPlayback component, and a button to
jump to a specified cue point.
To seek to a specified duration:
1. Create a new Flash document called seekduration.fla.
2. Drag an instance of the FLVPlayback component from the Components panel (Window
> Components).
The component is in the FLVPlayback - Player 8 folder.
3. Select the component and open the Property inspector (Window > Properties >
Properties).
4. Type my_flvPb in the Instance Name text box.
5. Drag an instance of the Button component from the Components panel to the Stage.
6. Select the Button component and type my_button in the Instance Name text box.
7. Select Frame 1 on the Timeline and type the following code in the Actions panel:
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);
}
8.
Select Control > Test Movie to test your code.
When you click the button, the video playhead moves to the duration that you specify:
2 seconds into the video.
To add seeking functionality with the FLVPlayback component:
1. Create a new Flash document called seek1.fla.
2. Drag an instance of the FLVPlayback component from the Components panel (Window
> Components).
The component is in the FLVPlayback - Player 8 folder.