622 Working with Images, Sound, and Video
9. Type the following code in the Actions panel:
// Create a NetConnection object.
var netConn:NetConnection = new NetConnection();
// Create a local streaming connection.
netConn.connect(null);
// Create a NetStream object and define an onStatus() function.
var nStream:NetStream = new NetStream(netConn);
// Attach the NetStream video feed to the Video object.
my_video.attachVideo(nStream);
// Set the buffer time.
nStream.setBufferTime(30);
// Being playing the FLV file.
nStream.play("http://www.helpexamples.com/flash/video/
lights_short.flv");
// Trace the metadata.
nStream.onMetaData = function(myMeta) {
for (var i in myMeta) {
trace(i + ":\t" + myMeta[i])
}
};
10.
Select Control > Test Movie to test your code.
You see the following information in the Output panel:
canSeekToEnd:true
audiocodecid:2
audiodelay:0.038
audiodatarate:96
videocodecid:4
framerate:15
videodatarate:400
height:213
width:320
duration:8.04
You can also use the following format to display most metadata information. For example, the
following code shows the duration of an FLV file:
nStream.onMetaData = function(myMeta) {
trace("FLV duration: " + myMeta.duration + " sec.");
};
This format cannot trace cuePoint metadata information. For information on tracing cue
points, see “Tracing cue points from an FLV file” on page 611.
NOTE
If your video does not have audio, the audio-related metadata information (such as
audiodatarate) returns undefined because no audio information is added to the
metadata during encoding.