Recipe 16.8.
Listening for Cue Points
Problem
You want
to listen for cue points
encoded in the FLV.
Solution
Use an onCuePoint( ) callback.
Discussion
The FLV format allows you to embed cue points
within the file. You can use cue points for many purposes, such
as:
You have to embed the cue points in the FLV file
using one of the FLV encoders such as the Flash Video Exporter (which ships
with Flash Professional), On2
Flix (http:// www.on2.com), or Sorenson
Squeeze (http://
www.sorensonmedia.com). When playing
back the video, the Flash Player receives a notification when a cue
point is reached. As with metadata, cue points don't use the
standard event model used by most of ActionScript 3.0. Rather, when
a cue point is reached Flash Player calls a callback method called
onCuePoint( ). As with onMetaData( ) the onCuePoint(
) method must be defined for an object that is assigned to the
client property of the NetStream object. The onCuePoint(
) method accepts one parameter, which is an object with the
following properties:
name
-
The name assigned to the cue point when
encoding.
time
-
The time at which the cue point occurs (in
seconds)
type
-
Either "event" or "navigation," depending on
which type was selected when encoding
parameters
-
An associative array with string key/value pairs
assigned when encoding the FLV
The following illustrates one way in which you
can create a client object, assign the onCuePoint reference,
and assign the client object to the NetStream object:
var client:Object = new Object( );
client.onCuePoint = onCuePoint;
videoStream.client = client;
Then define the method appropriately:
private function onCuePoint(cuePoint:Object):void {
trace(cuePoint.name + " " + cuePoint.time);
}
See Also
Recipe
16.4
|