VideoPlayer.as

Saturday February 9th, 2008

If you look through the Flash CS3 documentation, you’ll come across 3 different ways to handle FLV (Flash Video) files. The first, is an old AS2 favourite, the Video class. This low level video implementation does little more than you’d expect. In fact, in order to stream video, you use a NetStream object in conjunction with the Video class. Alone, it does little more than display an FLV file. The second implementation is the packaged FLVPlayback component. As far as implementation goes, this component is the Cadillac of video handlers. With a built in NetStream object and more events than you’ll ever need, the only drawback to this component is that it is a component. With a 50Kb overhead, and a pre-defined interface, the glorious implementation is overshadowed by the fact that skinning the component is the only way to get a custom look. Even at that, it can come off a skinned component and really, who wants one of those?

The third video implementation is the VideoPlayer class, this little gem is the ultimate solution for FLV files. With the high level implementation of the FLVPlayback and low level overhead of the Video class, this bad boy is the best of both worlds – if you can manage to use it. What I’m getting at there is that using

import fl.video.VideoPlayer;

can throw any of a number of compile errors. According the docs, you can solve this problem by placing an instance of the FLVPlayback in your .fla library and then opt instead to use the VideoPlayer class (an FLVPlayback, in fact, wraps a VideoPlayer). While the solution works as expected, you are still left with that annoying 50Kb footprint from the FLVPlayback component, so it seems as though you have to make a sacrifice in order to make use of this wonderful object.

Of course, me being as stubborn as I am, I refused to accept this situation as the only solution and I began digging. I tried all kinds of imports. Nothing. I tried variations of FLVPLayback components in the file, still no change. I even tried pointing a class path directly into the folder where the VideoPlayer.as file resides in the Flash libraries. No luck.

When it seemed as though hope was lost, I brought up the conflict and my co-worker (we’ll call him Jangles) sat down to have one last go at things… amazingly, he came up with a solution.

If you would like to use an instance of the VideoPlayer class in AS3 projects without the overhead of the FLVPlayback component, you must edit your class path settings (Edit/Preferences/Actionscript/Language) to reflect the location of the fl package (..\Adobe Flash CS3\en\Configuration\Component Source\ActionScript 3.0\FLVPlayback). From that point onward, you are free to use this incredible video implementation in all of its glory.

Sharing is Caring
  • Reddit
  • Digg
  • Facebook
  • Twitter
  • del.icio.us
  • StumbleUpon

Comments

VideoPlayer.as has no comments. Be the first.

Leave a comment




* Denotes required fields. But you knew that.