View comments | RSS feed

NetStream.onMetaData

Availability

Usage

public onMetaData = function(infoObject:Object) {}

Parameters

infoObject An object containing one property for each metadata item.

Returns

Nothing.

Description

Event handler; invoked when the Flash Player receives descriptive information embedded in the FLV file being played.

The Flash Video Exporter utility (version 1.1 or later) embeds a video's duration, creation date, data rates, and other information into the video file itself. Different video encoders embed different sets of metadata.

This handler is triggered after a call to the NetStream.play() method, but before the video playhead has advanced.

In many cases, the duration value embedded in FLV metadata approximates the actual duration but is not exact. In other words, it will not always match the value of the NetStream.time property when the playhead is at the end of the video stream.

Example

The code in this example starts by creating new NetConnection and NetStream objects. Then it defines the onMetaData() handler for the NetStream object. The handler cycles through every named property in the infoObject object that is received and prints the property's name and value.

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

ns.onMetaData = function(infoObject:Object) {
    for (var propName:String in infoObject) {
        trace(propName + " = " + infoObject[propName]);
    }
};

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

The code in this example causes the following information to be displayed:

canSeekToEnd = true
      videocodecid = 4
      framerate = 15
      videodatarate = 400
      height = 215
      width = 320
      duration = 7.347

The list of properties varies depending on the software that was used to encode the FLV file.


Comments


Matt Poole said on Oct 31, 2005 at 4:47 AM :
You need to make sure that your instrincsic NetStream Class defines the onMetaData Method. If it doesnt put this line in some after onStatus...

function onMetaData(info:Object):Void;
No screen name said on Mar 27, 2006 at 11:19 AM :
It doesn't work with Flash MX 2004.
Must use Flash 8 to compile.
No screen name said on Jan 14, 2007 at 7:46 PM :
It does work with Flash MX 2004.

Find the NetStream.as file:
[local settings]ocal settings\application data\macromedia\flash mx 2004\en\configuration\classes\netstream.as
or
c:\program files\macromedia\flash mx 2004\en\first run\classes

add this line:
function onmetadata(info:object):void;

now you will not get an error when using onmetadata!

 

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/00000584.html