Flash: Playing FLV/F4V Videos With Script
February 22, 2010

Playing F4V

F4V is the next incarnation of Flash Video which supports H.264 video (MPEG-4), which is more efficient for HD quality videos.   More about F4F:  To play F4V, the player must be Flash player 9

In many cases, the existing FLV player code can be used to play F4V.  The key is to republish the swf in Flash CS4 and to target Flash Player 9+.  Also, make sure that F4V file is properly associated with in the server:


This example is written in Flash CS4 in order to demonstrate F4V playback, but the steps are the same in CS3 (just replace the video filename: example.f4v with a flv file.  Starting with a new Flash project, insert a Video object into the Library.  The option is in the Library window option menu.


Name the symbol.


Add it onto the stage, and name it.  In this example, I name it: video.


Add the code below.  It’s a barebone code to play FLV, and not designed to be robust.  A related post on how to use Flash Component is here:

var mNetConnection:NetConnection=new NetConnection();

var mNetStream:NetStream=new NetStream(mNetConnection);
mNetStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStreamStatusEvent);

function onNetStreamStatusEvent(event:NetStatusEvent):void
  if ( == "NetStream.Play.Start")
  if ( == "NetStream.Play.StreamNotFound")
    trace("Video Not Found");
  if ( == "NetStream.Buffer.Full")

function onMetaData(metadata:Object):void

The line:


is to indicate how many second of the video should be preloaded before playback start.

The line:


is to indicate that this class will handle the onMetaData call (if you’re not doing anything with the metadate, the function can be left blank).  Without it, this error may appear:

Error #2044: Unhandled AsyncErrorEvent:.
text=Error #2095: was unable to invoke callback onMetaData.
Error #1069: Property onMetaData not found on and there is no default value.

The example code can be downloaded here.  It is saved in Flash CS4.
Credit for the video used in the xample: The Internet Archive, item: Computer Chronicle 2000.  I trimmed the video to about 3.5 minutes for storage reason, watch the full 20+ minutes video at Computer Chronicle 2000

The encoder used is iSkysoft video converter trial version.