- Types of Cue Points
- Embedding Cue Points
- Adding Seek Functionality Using Cue Points
- Adding Seek Functionality, Method 2
- Using Cue Points to
- Conclusion
Adding Seek Functionality Using Cue Points
To give you some idea of how cue points can be used in your Flash Video projects, let me demonstrate how to use them to add seek functionality to a playback interface.
The seekToNavCuePoint() method of the FLVPlayback component locates the cue point in the FLV file with the specified name, at or after the specified time. You can specify a name as a string (such as "part1" or "theWedding").
You can also use the seekToNextNavCuePoint() method, which seeks to the next navigation cue point, based on the current playheadTime. You can pass the method a parameter, time, which is the starting time from where to look for the next navigation cue point. The default value is the current playheadTime.
A third option is to seek to a specified duration of the FLV file by using the seek() method.
Here is a demonstration of how to seek to a specified cue point:
- Create a new Flash document called seek1.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 my_button in the
Instance Name text box (see Figure 6).
Figure 6 The Flash Stage as it should appear at the end of step 6.
- Select Frame 1 on the Timeline and type the following code in the Actions
pane (see Figure 7):
import mx.video.FLVPlayback; var my_flvPb:FLVPlayback; my_flvPb.autoPlay = false; my_flvPb.contentPath = "http://www.helpexamples.com/flash/video/cuepoints.flv"; my_button.label = "Next cue point"; function clickMe(){ my_flvPb.seekToNextNavCuePoint(); } my_button.addEventListener("click", clickMe);
Figure 7 Carefully enter this code into the Actions pane.
- Select Control > Test Movie to test your code.
The line of code my_flvPb.contentPath = browses to a video clip, cuepoints.flv, located on the Adobe Help Examples server and loads it into the FLVPlayback component. This cuepoints.flv file contains three navigation cue points: one each near the beginning, middle, and end of the video clip. When you click the button, the FLVPlayback instance seeks to the next cue point until it reaches the last cue point in the video file.