View comments | RSS feed

NetStream.onCuePoint

Availability

Usage

public onCuePoint = function(infoObject:Object) {}

Parameters

infoObject An object with the following 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

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

Returns

Nothing.

Description

Event handler; invoked when an embedded cue point is reached while an FLV file is playing. 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.

The following are two types of cue points that can be embedded in an FLV file:

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.

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");

The code in this example 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

NetStream.onMetaData


Comments


No screen name said on Oct 12, 2005 at 3:10 PM :
time, type and properties seem to have the exact same description.

This can not be correct.
MM tech writer said on Oct 12, 2005 at 3:54 PM :
Thanks, Jerry.

The "type" property description should be changed to:
The type of cue point that was reached: either "navigation" or "event".


The "properties" property name should be changed to "parameters" (no quotes) and the description should be:
An associative array of name/value pair strings specified for this cue point. Any valid string can be used for the parameter name or value.

I've made the change in the documentation for the next doc update.

Jody

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/fms/2/docs/00000583.html