Using cue points and metadata

Use
the NetStream callback methods to capture and process cue point
and metadata events as the video plays.

Using cue points

The following table describes the callback methods that
you can use to capture F4V and FLV cue points in Flash Player and
AIR.

Runtime

F4V

FLV

Flash Player 9/ AIR1.0

OnCuePoint

OnMetaData

Flash Player 10

OnCuePoint

OnMetaData

OnMetaData

OnXMPData

OnXMPData

The following example uses a simple for..in loop
to iterate over each of the properties in the infoObject parameter
that the onCuePoint()function receives. It calls
the trace() function to display a message when it receives cue point
data:

Using video metadata

You can use the OnMetaData() and OnXMPData() functions
to access the metadata information in your video file, including
cue points.

Using OnMetaData()

Metadata
includes information about your video file, such as duration, width, height,
and frame rate. The metadata information that is added to your video
file depends on the software you use to encode the video file.

Using the information object

The
following table shows the possible values for video metadata that
are passed to the onMetaData() callback function
in the Object that they receive:

Parameter

Description

aacaot

AAC audio object type; 0, 1, or 2 are supported.

avclevel

AVC IDC level number such as 10, 11, 20,
21, and so on.

avcprofile

AVC profile number such as 55, 77, 100,
and so on.

audiocodecid

A string that indicates the audio codec
(code/decode technique) that was used - for example “.Mp3” or “mp4a”

audiodatarate

A number that indicates the rate at which
audio was encoded, in kilobytes per second.

audiodelay

A number that indicates what time in the
FLV file "time 0" of the original FLV file exists. The video content
needs to be delayed by a small amount to properly synchronize the
audio.

canSeekToEnd

A Boolean value that is true if
the FLV file is encoded with a keyframe on the last frame, which
allows seeking to the end of a progressive -download video file.
It is false if the FLV file is not encoded with
a keyframe on the last frame.

cuePoints

An array of objects, one for each cue point
embedded in the FLV file. Value is undefined if the FLV file does
not contain any cue points. Each object has the following properties:

type: a string that specifies the type of
cue point as either "navigation" or "event".

name: a string that is the name of the cue
point.

time: a number that is the time of the cue
point in seconds with a precision of three decimal places (milliseconds).

parameters: an optional object that has
name-value pairs that are designated by the user when creating the
cue points.

duration

A number that specifies the duration of
the video file, in seconds.

framerate

A number that is the frame rate of the FLV
file.

height

A number that is the height of the FLV file,
in pixels.

seekpoints

An array that lists the available keyframes
as timestamps in milliseconds. Optional.

tags

An array of key-value pairs that represent
the information in the “ilst” atom, which is the equivalent of ID3
tags for MP4 files. iTunes uses these tags. Can be used to display
artwork, if available.

trackinfo

Object that provides information on all
the tracks in the MP4 file, including their sample description ID.

videocodecid

A string that is the codec version that
was used to encode the video. - for example, “avc1” or “VP6F”

videodatarate

A number that is the video data rate of
the FLV file.

videoframerate

Framerate of the MP4 video.

width

A number that is the width of the FLV file,
in pixels.

The following table shows the possible
values for the videocodecid parameter:

videocodecid

Codec name

2

Sorenson H.263

3

Screen video (SWF version 7 and later only)

4

VP6 (SWF version 8 and later only)

5

VP6 video with alpha channel (SWF version
8 and later only)

The following table shows the possible
values for the audiocodecid parameter:

audiocodecid

Codec Name

0

uncompressed

1

ADPCM

2

Mp3

4

Nellymoser @ 16 kHz mono

5

Nellymoser, 8kHz mono

6

Nellymoser

10

AAC

11

Speex

Using onXMPData()

The onXMPData() callback function receives
information specific to Adobe Extensible Metadata Platform (XMP)
that is embedded in the Adobe F4V or FLV video file. The XMP metadata
includes cue points as well as other video metadata. XMP metadata
support is introduced with Flash Player 10 and Adobe AIR 1.5 and
supported by subsequent versions of Flash Player and AIR.

Note: In XMP data, time is stored as DVA Ticks rather than seconds.
To compute the cue point time, divide the start time by the framerate.
For example, the start time of 7695905817600 divided by a framerate
of 254016000000 equals 30:30.

To see the complete raw XMP metadata, which includes the framerate,
remove the comment identifiers (//’s) preceding the second and third trace() statements
at the beginning of the onXMPData() function.

Using image metadata

The onImageData event sends image data
as a byte array through an AMF0 data channel. The data can be in
JPEG, PNG, or GIF formats. Define an onImageData() callback
method to process this information, in the same way that you would
define callback methods for onCuePoint and onMetaData. The
following example accesses and displays image data using an onImageData() callback
method:

Using text metadata

The onTextData event sends text data through
an AMF0 data channel. The text data is in UTF-8 format and contains
additional information about formatting, based on the 3GP timed-text
specification. This specification defines a standardized subtitle
format. Define an onTextData() callback method
to process this information, in the same way that you would define
callback methods for onCuePoint or onMetaData.
In the following example, the onTextData() method
displays the track ID number and corresponding track text.

public function onTextData(textData:Object):void
{
// display the track number
trace(textData.trackid);
// displays the text, which can be a null string, indicating old text
// that should be erased
trace(textData.text);
}