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.du " 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
.
NO
TE
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.
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...