The following example shows how you can use the Flash FLVPlayback component that ships with Flash CS3 and Flash CS4 by copying the FLVPlaybackAS3.swc file into your Flex project’s /libs/ folder.

Full code after the jump.

Flash CS3
PC: \Adobe Flash CS3\en\Configuration\Components\Video\FLVPlaybackAS3.swc

Flash CS4
PC: \Adobe Flash CS4\Common\Configuration\Components\Video\FLVPlaybackAS3.swc

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/12/11/using-the-flash-flvplayback-control-in-flex/ -->
<mx:Application name="FLVPlayback_MXML_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:video="fl.video.*"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            private function flvPlayback_autoLayout(evt:Event):void {
                videoHolder.width = flvPlayback.width;
                videoHolder.height = flvPlayback.height;
                flvPlayback.x = 0;
                flvPlayback.y = 0;
            }
        ]]>
    </mx:Script>

    <video:FLVPlayback id="flvPlayback"
            source="http://www.helpexamples.com/flash/video/caption_video.flv"
            scaleMode="maintainAspectRatio"
            skin="SkinOverPlaySeekMute.swf"
            skinAutoHide="true"
            autoLayout="flvPlayback_autoLayout(event);" />

    <mx:ApplicationControlBar dock="true">
        <mx:Button id="btn"
                label="Play Video"
                click="videoHolder.addChild(flvPlayback);" />
    </mx:ApplicationControlBar>

    <mx:Panel backgroundColor="red">
        <mx:UIComponent id="videoHolder" />
    </mx:Panel>

</mx:Application>
 
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

10 Responses to Using the Flash FLVPlayback control in Flex

  1. vijay says:

    thanks a lot……………
    Its useful to my work.

    by
    VJN

  2. James says:

    We were muttering about the lack of components for flv playback in Flex only this morning. Hopefully this will solve our woes – thanks!

  3. MechanisM says:

    Thanxx Peter!! Its very useful for me!!

  4. cris says:

    estou estudando flash cs4

  5. eChicho says:

    Muchas gracias, me ha ayudado mucho. (Thanks, help me so much)

  6. Guri says:

    Extremly utilitarian! Thanks

  7. Rhoby says:

    Merci beaucoup!!
    As usual, very useful tips on this site!!!
    thx a lot Peter !!!!

  8. bingeboy says:

    Hi I’m very new to flex and I’ve been working with your examples and they have a been a big help.

    I’m having an issue adding the FLVPlaybackAS3.swc to the lib folder. I’m using Textmate on OSX to complete my swf files and I can’t seem to sort out where I put this file to the code will compile correctly. Any help on this would be great.

    Thanks

  9. Lavanya says:

    Hi,

    This helped me a lot, i was facing problems with videodisplay component, hopefully i got this.

    Thanks a lot Peter.

  10. sagar kapadiya says:

    nice…it’s good

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree