Use a Datagrid to Verify and Test Dozens of Videos at Once.

So, you have a couple hundred videos and you need to find out if the duration, cue point information, etc. is correct. What do you do? Well, you could use the MetaData Tester I gave you in my last post about this topic and test the videos one at a time… Or you could load the videos information into a datagrid and see all of them at once.

You can see the example here.

So how do we do this… well, I am using the same PHP script referenced in my other posts on Flash video viewing and testing. This script crawls the directory and parses it into XML.

On stage, I have added a scrollpane to contain the Datagrid (it could get very big horizontally and AS2 datagrids don’t scroll horizontally, if you are using AS3 you don’t need this scrollpane component). In my library I have added a datagrid and put it inside a linked movieClip called videoGrid for placement on stage.

Once my library is all ready, I open the actions editor to write the script that will set up an iterator “currVideo” to store the current video that needs to be loaded in the player. I also create two arrays “allVideos” and “videosData”. The array “allVideos” will be used as the rows in the datagrid and “videosData” will populate the columns in each row. So, how does this all come together:

var currVideo:Number = new Number();
var allVideos:Array = new Array();
var videosData:Array = new Array();
var metalistenerObject:Object = new Object();
metalistenerObject.metadataReceived = function(eventObject:Object):Void {
var videosData:Array = new Array();
videosData[0] = myPlayer.contentPath;
videosData[1] = myPlayer.metadata.cuePoints.length
videosData[2] = myPlayer.metadata.framerate;
videosData[3] = myPlayer.metadata.height;
videosData[4] = myPlayer.metadata.width;
videosData[5] = myPlayer.metadata.duration;
videosData[6] = myPlayer.metadata.videocodecid;
videosData[7] = myPlayer.metadata.videodatarate;
videosData[8] = myPlayer.metadata.audiodatarate;
for(i=0;i<myPlayer.metadata.cuePoints.length;i++) {
videosData[i+9] = myPlayer.metadata.cuePoints[i].type.substr(0,1) + " : " + myPlayer.metadata.cuePoints[i].name + " : " +  myPlayer.metadata.cuePoints[i].time;
scrolly.spContentHolder.videoGrid.addItem({file:videosData[0].substr(7,videosData[0].length) , CP:videosData[1], FPS:videosData[2], H:videosData[3], W:videosData[4], D:videosData[5], Codec:videosData[6], Video:videosData[7], Audio:videosData[8], CP1:videosData[9], CP2:videosData[10], CP3:videosData[11], CP4:videosData[12], CP5:videosData[13], CP6:videosData[14], CP7:videosData[15], CP8:videosData[16], CP9:videosData[16], CP10:videosData[17], CP11:videosData[18], CP12:videosData[19], CP13:videosData[20], CP14:videosData[21], CP15:videosData[22], CP16:videosData[23], CP17:videosData[24], CP18:videosData[25], CP19:videosData[26], CP20:videosData[27]});
currVideo = currVideo+1;;"videos/" + video_arr[currVideo].video);
//trace(currVideo + " : " + video_arr[currVideo].video);
scrolly.spContentHolder.videoGrid.getColumnAt(0).width = 200; //file
scrolly.spContentHolder.videoGrid.getColumnAt(1).width = 23; //cuepoints
scrolly.spContentHolder.videoGrid.getColumnAt(2).width = 30; //frame rate
scrolly.spContentHolder.videoGrid.getColumnAt(3).width = 28; //height
scrolly.spContentHolder.videoGrid.getColumnAt(4).width = 28; //width
scrolly.spContentHolder.videoGrid.getColumnAt(5).width = 33; //duration
scrolly.spContentHolder.videoGrid.getColumnAt(6).width = 25; //codec
scrolly.spContentHolder.videoGrid.getColumnAt(7).width = 30; //video
scrolly.spContentHolder.videoGrid.getColumnAt(8).width = 30; //audio
scrolly.spContentHolder.videoGrid.getColumnAt(9).width = 120; //cue point 1
scrolly.spContentHolder.videoGrid.getColumnAt(10).width = 120; //cue point 2
scrolly.spContentHolder.videoGrid.getColumnAt(11).width = 120; //cue point 3
scrolly.spContentHolder.videoGrid.getColumnAt(12).width = 120; //cue point 4
scrolly.spContentHolder.videoGrid.getColumnAt(13).width = 120; //cue point 5
scrolly.spContentHolder.videoGrid.getColumnAt(14).width = 120; //cue point 6
scrolly.spContentHolder.videoGrid.getColumnAt(15).width = 120; //cue point 7
scrolly.spContentHolder.videoGrid.getColumnAt(16).width = 120; //cue point 8
scrolly.spContentHolder.videoGrid.getColumnAt(17).width = 120; //cue point 9
scrolly.spContentHolder.videoGrid.getColumnAt(18).width = 120; //cue point 10
scrolly.spContentHolder.videoGrid.getColumnAt(19).width = 120; //cue point 11
scrolly.spContentHolder.videoGrid.getColumnAt(20).width = 120; //cue point 12
scrolly.spContentHolder.videoGrid.getColumnAt(21).width = 120; //cue point 13
scrolly.spContentHolder.videoGrid.getColumnAt(22).width = 120; //cue point 14
scrolly.spContentHolder.videoGrid.getColumnAt(23).width = 120; //cue point 15
scrolly.spContentHolder.videoGrid.getColumnAt(24).width = 120; //cue point 16
scrolly.spContentHolder.videoGrid.getColumnAt(25).width = 120; //cue point 17
scrolly.spContentHolder.videoGrid.getColumnAt(26).width = 120; //cue point 18
scrolly.spContentHolder.videoGrid.getColumnAt(27).width = 120; //cue point 19
scrolly.spContentHolder.videoGrid.getColumnAt(28).width = 120; //cue point 20
scrolly.spContentHolder.videoGrid.getColumnAt(29).width = 120; //cue point 21
scrolly.spContentHolder.videoGrid.getColumnAt(30).width = 120; //cue point 22
myPlayer.addEventListener("metadataReceived", metalistenerObject);

You could certainly economize the code above by writing more loops and possibly using array length data a bit more frugally, but it works. It takes a bit of time to crawl a large directory and load each video in order to get the metadata for each one, so once you load this webpage, go check you email or send a twitter or get some coffee. ;-) We used this datagrid to help test and view the videos for our Flash video based site where you can send personalized video message to friends. Go check it out.

You can download the FLA file with all the code above in it, here.

Posted on


  1. explore talent Jan 1

    I am using the same PHP script referenced in my other posts on Flash video viewing and testing. This script crawls the directory and parses it into XML.

  2. Scary Videos Jul 4

    Thanks for the PHP script. This is a great tip. I use a lot of videos and custom flash eVARs. I appreciate the info, Bro. Been following your blog for a while. Thanks!

Leave a reply