Posts Tagged ‘f4v’

Mar 01 2011

FLV logoWhen working with Flash video I always end up using extra time finishing a project. This is mainly because I get these project not so often. So everytime I have to create video content I have to brush up my as3 video skills.

In this posts I will point out a few pitfalls when doing a Flash as3 movie project.

Decide where the videocontent is placed

This is handy to know beforehand. It saves a lot of time and effort to do it first time right. Are you going to progressively download the movie or is it streaming? Does it come from a flash mediaserver? Know what you are working with before you start.

Create a prototype

Start with creating a prototype so you know the pitfalls. And you know the steps to recreate the experience. Afterwards you can tweak layout, performance etc.

When using Cue Points

FLV logoMake sure you export your movie as .flv. F4v doesn’t support cue points. Cue points are a feature of the FLV video container format. FLV is a proprietary format developed specifically to complement Adobe Flash.

Cue Point code

Handling cuepoints in ActionSctipt3 is easy once you know the drill. One of the simplest methods is to create a simple Object which processes the onCuePoint and onMetaData event handlers in ActionScript 3.0. You can see an example of this in the following code:

var customClient:Object = new Object();
customClient.onCuePoint = cuePointHandler;
customClient.onMetaData = metaDataHandler;

var myVideo:Video = new Video();
addChild(myVideo);

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = customClient;
myVideo.attachNetStream(ns);
ns.play("http://www.helpexamples.com/flash/video/cuepoints.flv");

function cuePointHandler(infoObject:Object):void
{
    trace("cuePoint");
}
function metaDataHandler(infoObject:Object):void
{
    trace("metaData");
}

Or you can create a CustomClient class which handles the meta data and cuepoints.

package
{
	public class CustomClient
	{
		public function onMetaData(info:Object):void
		{
			trace("metadata: duration=" + info.duration + " width=" + info.width + " height=" + info.height + " framerate=" + info.framerate);
		}
		public function onCuePoint(info:Object):void
		{
			trace("cuepoint: time=" + info.time + " name=" + info.name + " type=" + info.type);
		}
	}
}

These are the basics to start embedding video content.

Other resources