Easily learn more about your Flash Videos – MetaData Viewer


Building off of my last post on making a Flash Video Jukebox with PHP, we’ll now be adding some functionality to it that allows us to see more information about our FLV file currently playing. All of the metadata. Duration, Codec Type, Cue Point Information, everything. Very useful when QA-ing a batch of files that need to be formatted a certain way, right?

I built this tool to help me and the video team test our assets for CluckHere.com, as there were too many videos and as always not enough time! Because this made checking the videos far quicker than the alternative of dropping them into our application every time we rendered a new clip, it was a godsend. I hope you can find this code useful, too.

Let’s get started.

So after you have a combobox and a FLV Playback component on stage we’ll need to add some more code to interpret the metadata and then send it out to a textarea for read out. I have left a few trace statements in here but have them commented out in case you prefer that method of debugging to onscreen UI elements.

var metalistenerObject:Object = new Object();
metalistenerObject.metadataReceived = function(eventObject:Object):Void {
var messageToOutput:String;
messageToOutput = “canSeekToEnd is ” + myPlayer.metadata.canSeekToEnd + “\n”;
messageToOutput += “Number of cue points is ” + myPlayer.metadata.cuePoints.length + “\n”;
messageToOutput += “=/=/=/=/=\n”;
//trace(“canSeekToEnd is ” + myPlayer.metadata.canSeekToEnd);
//trace(“Number of cue points is ” + myPlayer.metadata.cuePoints.length);
//trace(“=/=/=/=/=”);
for(i=0;i<myPlayer.metadata.cuePoints.length;i++) {
cuePointsArray[i].name = myPlayer.metadata.cuePoints[i].name;
cuePointsArray[i].type = myPlayer.metadata.cuePoints[i].type;
cuePointsArray[i].time = myPlayer.metadata.cuePoints[i].time;

messageToOutput += “–CuePoint-” + i + “-name: ” + myPlayer.metadata.cuePoints[i].name + “\n”;
messageToOutput += “–CuePoint-” + i + “-type: ” + myPlayer.metadata.cuePoints[i].type + “\n”;
messageToOutput += “–CuePoint-” + i + “-time: ” + myPlayer.metadata.cuePoints[i].time + “\n”;
messageToOutput +=”–CuePoint-” + i + “-parameters: ” + myPlayer.metadata.cuePoints[i].parameters + “\n”;
messageToOutput += ” \n”;
//trace(“–CuePoint-” + i + “-name: ” + myPlayer.metadata.cuePoints[i].name);
//trace(“–CuePoint-” + i + “-type: ” + myPlayer.metadata.cuePoints[i].type);
//trace(“–CuePoint-” + i + “-time: ” + myPlayer.metadata.cuePoints[i].time);
//trace(“–CuePoint-” + i + “-parameters: ” + myPlayer.metadata.cuePoints[i].parameters);
//trace(” “);
}
messageToOutput += “=/=/=/=/=\n”;
messageToOutput += “Frame rate is ” + myPlayer.metadata.framerate + “\n”;
messageToOutput += “Height is ” + myPlayer.metadata.height + “\n”;
messageToOutput += “Width is ” + myPlayer.metadata.width + “\n”;
messageToOutput += “Duration is ” + myPlayer.metadata.duration + ” seconds” + “\n”;
messageToOutput += “Video Codec is ” + myPlayer.metadata.videocodecid + “\n”;
messageToOutput += “Video Data Rate is ” + myPlayer.metadata.videodatarate + “\n”;
messageToOutput += “Audio Data Rate is ” + myPlayer.metadata.audiodatarate + “\n”;
_root.textArea.text = messageToOutput;
_root.totalTime_txt.text = myPlayer.metadata.duration;
};
myPlayer.addEventListener(“metadataReceived”, metalistenerObject);

This would probably be good enough, right? Well another thing I wanted to know was exactly when are cue points occurring. In order to do that, we need to set up another listener…

var cplistenerObject:Object = new Object();
cplistenerObject.cuePoint = function(eventObject:Object):Void {
cp_burn.play();
cp_burn.cuePointName.text = eventObject.info.name;
currPoint = currPoint++;
//trace(“Cue Listener Hit”);
};
myPlayer.addEventListener(“cuePoint”, cplistenerObject);

That’ll do it… When a cue point gets hit, a little cigarette burn animation plays on screen along with the name of the cuepoint in a text field to let the viewer know that the cue point was reached.

If you want to see it in action check it out here. You can also download the source file here and pretty easily get this running yourself.

Bonus points to anyone who knows who the cigarette burn animation is. ;-)

Posted on


5 comments

  1. aaron Oct 25

    is this in actionscript 2.0? I’m having trouble accessing metadata in actionscript 3.0

  2. aaron Oct 25

    yea – i just downloaded the source and it appears to be for actionscript 2.0. FYI – this will not work in actionscript 3.0

  3. aaron Oct 25

    Sorry for all the comments, but if anyone else is as frustrated as I am with the huge differences from actionscript 2.0 to 3.0 keep in mind that :Void has to be lowercase :void in actionscript 3.0!!! This took me way too long to figure out. Plus I keep getting these 1118 errors all over the place. :(

  4. Flash Banner Jun 13

    aaron thanks for sharing this. I was having the same problem your comments helped me a lot and saved a lot of time.

  1. Use a Datagrid to Verify and Test Dozens of Videos at Once. | Visualrinse | Design and Development by Chad Udell

Leave a reply