Posted At : January 15, 2009 4:12 PM
| Posted By : Stefan Richter
| Related Categories:
Components
,
FMS
,
Flex
Alongside the recently released Flash Media Server 3.5 and its Dynamic Streaming and DVR capabilities Adobe have also pushed out an updated version of their FLVPlayback component. As Andrew Shorten explains, this component can be used in both Flash or Flex since it is not based on UIComponent. In short, FLVPlayback brings a more fully featured video component to Flex (dare I say finally), and while most of us have a love-hate relationship with this baby it's certainly good news for the platform, and you no longer have to 'port' your Flash based FLVPlayback component to Flex now (as I did here).
I gave the component a quick test drive and wrapped it into a Flex project that you can download and try yourself. The demo below uses FMS for streaming, the downloadable project uses a progressive download. Note that I'm using Oleg's excellent Swfobject 2.1 Flex template and I added the allowFullScreen parameter for this example and removed the history management (not really needed for a plain video player). Sources here.
It seems there is a bug in the sourcecode of the NCManager class, I noticed that when I copied the NCManager class in order to create a custom NCManager class for one of my applications. A call to onconnected is missing in the netStatusHandler (line 1439 in the version I downloaded 2 days ago from the Adobe website)
Just add the following line in the source after the call to cleanConns() when the "NetConnection.Connect.Success" status code has been received: onConnected(_nc, 0);
Besides that the 2.5 FLVPlayback component seems to be just a minor update to the flvPlayback component you ported earlier, mainly adding the DVR functionality. Including the flvPlayback sources in Flex projects is pretty cool because its easy to extend or change some of it's behaviour.
That's not a bug in NCManager.as, it's actually that way by design. The NCManager class is designed to work with a special sever-side application that when a client connects, the server initiates bandwidth detection. The sever-side app will then call onBWDone on the NetConnection's client object, which will then call onConnected. Also, if you wish to use the new Dynamic Streaming features in the component, you will need to base your custom NCManager off of NCManagerDynamicStream so that you get the correct properties and methods.
Like Stefan said, you'll need to make sure you set the target player for 10.0.0 inside of the project settings and have the 3.2 SDK. Flash Player 9 and 10 have different namespaces for AS3, so in order to get all the classes in the new namespace it has to use the compiler for FP10.
Hey Stefan, great timing for me thanks for pointing this out.
Have you tried this in the latest Gumbo SDK? I've gone back to 3.2 now and it works well but if I remember rightly there was an error about "illegal override on method play2()". Just checking in with you to see if you've tried it on in 4.0?
Hello, everything its working fine and I'd like to expand this functionallities, I've created a function to add the FLVPlayback component according to the parameters:
private function addFLVPlayback(xpos:Number,ypos:Number):void {...}
but i'd like to know how to put this componet inside a Panel or another container.
Sorry Richard Leggett, I did not get the idea.. I'm very newbie to Flex, here is it:
... private function addFLVPlayback(xpos:Number,ypos:Number):void { var vid:FLVPlayback = new FLVPlayback(); var ui:UIComponent = new UIComponent(); ui.x = xpos; ui.y = ypos; this.addChild( ui ); rawChildren.addChild( vid );
A call to onconnected is missing in the netStatusHandler (line 1439 in the version I downloaded 2 days ago from the Adobe website)
Just add the following line in the source after the call to cleanConns() when the "NetConnection.Connect.Success" status code has been received:
onConnected(_nc, 0);
Besides that the 2.5 FLVPlayback component seems to be just a minor update to the flvPlayback component you ported earlier, mainly adding the DVR functionality.
Including the flvPlayback sources in Flex projects is pretty cool because its easy to extend or change some of it's behaviour.
1046: Type was not found or was not a compile-time constant: NetStreamPlayOptions.
Any idea what might be wrong?
also make sure you change your project properties to target Flash Player 10.
Thanks!
Have you tried this in the latest Gumbo SDK? I've gone back to 3.2 now and it works well but if I remember rightly there was an error about "illegal override on method play2()". Just checking in with you to see if you've tried it on in 4.0?
sorry but I haven't tried in Gumbo yet.
Cheers
Stefan
I have the 3.2 and am using 10.0.0. How do I get around this problem?
private function addFLVPlayback(xpos:Number,ypos:Number):void
{...}
but i'd like to know how to put this componet inside a Panel or another container.
is that possible?
One way is to call rawChildren.addChild(flvPlayback) in the parent container.
...
private function addFLVPlayback(xpos:Number,ypos:Number):void
{
var vid:FLVPlayback = new FLVPlayback();
var ui:UIComponent = new UIComponent();
ui.x = xpos; ui.y = ypos;
this.addChild( ui );
rawChildren.addChild( vid );
vid.width = 424;
vid.height = 240;
vid.autoPlay = false;
vid.source = "fuel.mp4";
vid.skinBackgroundColor = 0x990000;
vid.skin = "skins/SkinUnderPlayStopSeekFullVol.swf";
vid.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO;
vid.skinAutoHide = false;
}
]]>
</mx:Script>
<mx:Panel id="main" x="10" y="10" width="780" height="581" layout="absolute" title="DMTV Station">
<mx:Button x="10" y="287" label="Load DMTV" click="addFLVPlayback(20,20)"/>
</mx:Panel>
how can I add the FLVPlayback component into this Panel ?
Sorry for being redundant. I tried using rawChildren but i don't know where can I call the video.