13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with video<br />

var nc:NetConnection = new NetConnection();<br />

nc.connect(null);<br />

var ns:NetStream = new NetStream(nc);<br />

ns.cli<strong>en</strong>t = this;<br />

ns.play("video.flv");<br />

var vid:Video = new Video();<br />

vid.attachNetStream(ns);<br />

addChild(vid);<br />

function onMetaData(infoObject:Object):void<br />

{<br />

var key:String;<br />

for (key in infoObject)<br />

{<br />

trace(key + ": " + infoObject[key]);<br />

}<br />

}<br />

The previous code g<strong>en</strong>erates output like the following:<br />

width: 320<br />

audiodelay: 0.038<br />

canSeekToEnd: true<br />

height: 213<br />

cuePoints: ,,<br />

audiodatarate: 96<br />

duration: 16.334<br />

videodatarate: 400<br />

framerate: 15<br />

videocodecid: 4<br />

audiocodecid: 2<br />

If your video does not have audio, the audio-related metadata information (such as audiodatarate) returns<br />

undefined because no audio information is added to the metadata during <strong>en</strong>coding.<br />

In the previous code, the cue point information was not displaying. To display the cue point metadata, you can use the<br />

following function which recursively displays the items in an Object:<br />

Last updated 6/6/2012<br />

493

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!