Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Behavior 2: Seek to Time

Behavior 2: Seek to Time

The Seek to Time behavior allows you to jump to a specific time that you specify. Make sure you choose a time that exists within the length of the video to see the effect work. The following instructions show you how to add this behavior to a custom button.

To use this behavior:

  1. Add a Media Playback component to the Stage.
  2. Select the component and open the Component Inspector panel.
  3. Enter the URL parameter with the path to the video.
  4. Add a button to the Stage and select it.
  5. 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 Time from the list. The behavior’s dialog box opens (see Figure 2).

    figure 2

    Figure 2. The Seek to Time dialog box shows the target MediaDisplay (myMediaControl2) selected and the target time (1 sec.) entered in the field below.

  6. 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.
  7. In the Time to Seek To field, enter the number of seconds you would like to seek to.
  8. Click OK.

That’s it. Test the movie and click the button while the video is playing to see the video jump to the time you specified.

Here’s the code that is added to the button:

// Start Seek to Time Behavior
var m = myMediaControl2
m.play(Math.round(1));
// End Seek to Time 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