Behavior 1: Seek to Cue
Behavior 1: Seek to Cue
The Seek to Cue behavior allows you to jump to a time saved in a cue point within the media component. The following instructions show you how to add this behavior to a custom button.
To use this behavior:
- Add a Media Playback component to the Stage.
- Select the component and open the Component Inspector panel.
- Enter the URL parameter with the path to the video and add a name and time to a cue point field.
- Add a button to the Stage and select it.
-
Open the Behaviors panel and click the plus (+) icon to access the list of behavior categories. Select the Media Controls category and choose Seek to Cue from the list. The behavior’s dialog box opens (see Figure 1).
- In the dialog box, browse for the media playback instance in the target list in the top portion of the dialog box. This targets the instance name of the component displaying the video. A best practice is to use the Relative option for the path, as shown above. If you have problems adding paths to component buttons, try using the Absolute option instead.
- In the Add Cue Point Name field, enter the name of the cue point you saved in the Component Inspector panel.
- Click OK.
That’s it. Test the movie and click the button while the video is playing to see the video jump to the cuepoint time.
Here’s the code that is added to the button:
// Start Seek to Cue Behavior
var m = myMediaControl1;
var q = m.getCuePoint("cue1");
m.play(Math.round(q.time));
// End Seek to Cue Behavior
Tips:
- In the code, the cue time is rounded to the nearest second to produce the smoothest results for tracking. You can alter this to target shorter time signatures.
- When trying to seek to a timecode or event in an FLV, the playhead often jumps to the wrong time. This is because you can only seek to a whole keyframe within the video. If you try to seek to any other time, the playhead jumps to the nearest whole keyframe. The keyframe value is set at encode-time.
Comments