By including cue points in your video, you can assign navigation points that will allow you to seek to specific locations in the video and synchronize those locations to the content in the movie. If you haven't done so already, read up on the options available to you for creating cue points. Your easiest route will be to use the cuePoints parameter in the Component Inspector, but you may also embed cue points during video encoding or create cue points dynamically using ActionScript.
This page covers the following topics:
Tip: Seeking to a specific time within a progressive file only works accurately if navigation cue points are embedded at the time of encoding. Navigation cue points force the FLV to generate a whole keyframe at the location in the video where the cue point is added. This is necessary for the playhead to land on the exact spot in the footage as you are defining the navigation for a video file.
Beyond seeking to exact locations marked by navigation cue points, progressive video does not seek accurately at all times. If you scrub or seek to a time in the video that does not have a whole keyframe associated with it, the playhead will jump to the nearest whole keyframe. To accurately seek in all situations, you must use streaming video supplied by a Flash Media Server.
You can accurately seek to an embedded navigation cue point by using the cue point's name. The following steps show how to create a button that will seek to the cue point named 'introduction'.
import fl.video.*;
// Video component instance name
var flvControl:FLVPlayback = display;
var flvSource:String = "Call_to_Action.flv";
// Set video
flvControl.source = flvSource;
// Add seek functionality to the button
function seekHandler(event:MouseEvent):void
{
flvControl.seekToNavCuePoint("introduction")
}
seek_btn.addEventListener(MouseEvent.CLICK, seekHandler);
introduction cue point name in the code
with the name of your intended cue point.You can also seek to a specific time within your video.
// Add seek to time code
function seekToTimeHandler(event:MouseEvent):void
{
var sec:Number = 2;
flvControl.seek(sec);
}
seekToTime_btn.addEventListener(MouseEvent.CLICK, seekToTimeHandler);
sec variable value to use the time you'd
like to target.You can seek to a percentage to jump to a location by specifying the percent complete.
// Add seek to percent code
function seekToPercentHandler (event:MouseEvent):void
{
var percent:Number = 20;
flvControl.seekPercent(percent);
}
seekToPercent_btn.addEventListener(MouseEvent.CLICK, seekToPercentHandler);
percent variable value with the
percentage of time you'd like to target.Tip: The Seek to Percent behavior won't work if you use it with older FLV files that do not have metadata embedded in them. If this occurs, you can work around the problem by encoding the video to the FLV format again using Adobe Media Encoder CS4.
A related tangent to seeking is handling cue points. Embedded cue points are the key to successful navigation within progressive video. This technique is often used to let the video power synchronization in the user interface. The following steps demonstrate how to listen for video cue points and navigate to frame labels with the corresponding names.
// Add cue point handler code
function cuePointHandler(event:MetadataEvent):void
{
trace("name = "+event.info.name);
trace("time = "+event.info.time);
// Go to a frame label with the cue point name
gotoAndStop(event.info.name);
}
flvControl.addEventListener(MetadataEvent.CUE_POINT, cuePointHandler);
To see a working example, see flvplayback_programming4.fla in the sample files.