onCuePoint (NetStream.onCuePoint handler)

onCuePoint = function(infoObject:Object) {}

Invoked when an embedded cue point is reached while playing an FLV file. You can use this handler to trigger actions in your code when the video reaches a specific cue point. This lets you synchronize other actions in your application with video playback events.

There are two types of cue points that can be embedded in an FLV file.

The onCuePoint() event handler receives an object with these properties:

Property

Description

name

The name given to the cue point when it was embedded in the FLV file.

time

The time in seconds at which the cue point occurred in the video file during playback.

type

The type of cue point that was reached, either "navigation" or "event".

parameters

A associative array of name/value pair strings specified for this cue point. Any valid string can be used for the parameter name or value.

You can define cue points in an FLV file when you first encode the file, or when you import a video clip in the Flash Authoring tool by using the Video Import wizard.

The onMetaData() event handler also retrieves information about the cue points in a video file. However the onMetaData() event handler gets information about all of the cue points before the video begins playing. The onCuePoint() event handler receives information about a single cue point at the time specified for that cue point during playback.

Generally if you want your code to respond to a specific cue point at the time it occurs you should use the onCuePoint() event handler to trigger some action in your code.

You can use the list of cue points provided to the onMetaData() event handler to let your user start playing the video at predefined points along the video stream. Pass the value of the cue point's time property to the NetStream.seek() method to play the video from that cue point.

Availability: ActionScript 1.0; Flash Player 8

Parameters

infoObject:Object - An object containing the name, time, type, and parameters for the cue point.

Example

The code in this example starts by creating new NetConnection and NetStream objects. Then it defines the onCuePoint() handler for the NetStream object. The handler cycles through each named property in the infoObject object and prints the property's name and value. When it finds the property named parameters it cycles through each parameter name in the list and prints the parameter name and value.

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);

ns.onCuePoint = function(infoObject:Object) 
{
    trace("onCuePoint:");
    for (var propName:String in infoObject) {
        if (propName != "parameters")
        {
            trace(propName + " = " + infoObject[propName]);
        }
        else
        {
            trace("parameters =");
            if (infoObject.parameters != undefined) {
                for (var paramName:String in infoObject.parameters)
                {
                    trace(" " + paramName + ": " + infoObject.parameters[paramName]);
                }
            }
            else
            {
                trace("undefined");
            }
        } 
    }
    trace("---------"); 
}

ns.play("http://www.helpexamples.com/flash/video/cuepoints.flv");

This causes the following information to be displayed:

 onCuePoint:
 parameters =
 lights: beginning
 type = navigation
 time = 0.418
 name = point1
 ---------
 onCuePoint:
 parameters =
 lights: middle
 type = navigation
 time = 7.748
 name = point2
 ---------
 onCuePoint:
 parameters =
 lights: end
 type = navigation
 time = 16.02
 name = point3
 ---------

The parameter name "lights" is an arbitrary name used by the author of the example video. You can give cue point parameters any name you want.

See also

onMetaData (NetStream.onMetaData handler)


Flash CS3