
Page 1 of 3 In the last tutorial of this series, you learned how to create embedded navigation cue points with Flash Video (FLV) files. Such cue points are automatically recognized by the new FLVPlayback component that ships with Flash Pro 8, and most skins used by this component enable you to seek forward and backward among cue points. However, if you have several cue points in your FLV file or if you want to offer an alternative method of jumping to cue points, you need to code your own solution. Using ActionScript, you can read the cue points from a Flash Video (FLV) file and populate a list with the cue point names, or, alternatively, with additional data that you prescribe for each cue point. In this installment, you learn how to read navigation cue points from a Flash Video (FLV) file and populate a List component with the cue point names. In the next tutorial of this series, you learn how to encode an FLV file with extra data on each cue point.
CAUTION: In order to add navigation cue points to compressed Flash Video files with Flash 8, you need to use Flash Professional 8.
If you're using your own custom code to load and play Flash Video (FLV) files with the NetStream class, you can use the NetStream.onMetaData() method to read any cue point data that might exist in the video file. In the source files of this tutorial, extract the stella_dog_tricks.flv file, and perform the following steps:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.play("stella_dog_tricks.flv");
ns.onMetaData = function(oMeta:Object){
trace("onMetaData >");
trace("\tNumber of cue points: " + oMeta.cuePoints.length);
for(var i:Number = 0; i < oMeta.cuePoints.length; i++){
var oCue:Object = oMeta.cuePoints[i];
trace("\t\t" + i + ": " + oCue.name + ", " + oCue.type);
}
};
onMetaData >
Number of cue points: 3
0: trick_1, navigation
1: trick_2, navigation
2: trick_3, navigation
Tip: To review usage of the Cue Points tab in the Flash Pro 8 Video Import wizard, read my previous article in this series.
If you're using the FLVPlayback component, you can also read the cue point data from the FLV file when the metadataReceived event is broadcast by the component. To understand how this event works, perform the following steps:
import mx.video.FLVPlayback;
import mx.utils.Delegate;
var cfp:FLVPlayback;
function onVideoMeta(oEvent:Object):Void {
trace("onVideoMeta >");
// retrieve metadata from FLVPlayback instance
var oMeta:Object = oEvent.target.metadata;
// retrieve cue point data from video
var aCues:Array = oMeta.cuePoints;
// loop through cue point data and
// find navigation cue points
trace("\tcue points:");
for(var i:Number = 0; i < aCues.length; i++){
var oCue:Object = aCues[i];
trace("\t\t" + i + ": name: " + oCue.name + ", type: " + oCue.type);
}
}
cfp.addEventListener("metadataReceived", Delegate.create(this, onVideoMeta));
onVideoMeta >
cue points:
0: name: trick_1, type: navigation
1: name: trick_2, type: navigation
2: name: trick_3, type: navigation
Keywords
cue points, embedded, navigation cue points, FLVPlayback component