Playing around with Metadata & Cue Points

Adobe has a helpful intro to Cue Points & Metadata in Flash video.

I started off with this part of the tutorial:

Extending the NetStream class and adding methods to handle the callback methods

//...
var ns:NetStream = new NetStream(nc);
ns.client = new CustomClient2();
//...

and expanded the CustomClient class to see if I can squeeze more information out of the .flv file:

package 
{
    public class CustomClient2 
	{
		
		private var cuePointCount:int = 0;
				
        public function onMetaData(infoObject:Object):void 
		{
            trace("metadata");
			trace("duration =" + infoObject.duration);
			trace("width =" + infoObject.width);
			trace("height =" + infoObject.height);
			trace("framerate =" + infoObject.framerate + "\n");
        }

		public function onCuePoint(infoObject:Object):void 
		{
			cuePointCount += 1;
			switch(cuePointCount)
			{ //the flv has 3 cue points created @ encoding time
				case 1:
					trace("cue point VONE!");			
					cuePntDetails(infoObject);
					break;
				case 2:
					trace("cue point TWO!");							
					cuePntDetails(infoObject);
					break;
				case 3:
					trace("cue point THREEE!");							
					cuePntDetails(infoObject);
					break;
			}
		}
		
		public function cuePntDetails(infoObject):void 
		{
			trace("name: " + infoObject.name);
			trace("time: " + infoObject.time);
			trace("type: " + infoObject.type); //navigation or event
			trace("params: " + infoObject.parameters + "\n");
		}
		
		private function onPlayStatus(infoObject:Object):void 
		{ //only works with Flash Media Server / streaming video, not progressive download? 
			switch (infoObject.info.code) 
			{
				case "NetStream.Play.Complete":
					vidComplete();
					break;
			}
			trace(infoObject.info.code);
		}
		
		public function vidComplete():void  
		{
			trace("NetStream.Play.Complete = Video complete");	
		}		
    }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s