Creating a Web FLV Player

Converting video files to FLV files can be a great way to reduce the amount of bandwidth used to stream videos from your web site. This tutorial will take you through the basics of creating a Flash FLV player the MediaDisplay component in Flash 8 Professional.

Step 1. Create a new flash file and select Components from the Window menu (Ctrl+F7) and also Component Inspector (Alt+F7) You will need both of these toolbars to work with the MediaDisplay component.components

Step 2. Drag the MediaDisplay component off of the Components menu and onto your empty flash document. Resize it to the size you want the player to be on your page.

Step 3. Give it an instance name of “player” under properties.

Step 4. Bring up the component inspector and select the component in your flash file to get its settings. Make sure it is set to FLV and then choose the settings you want for it. Use preferred media size will limit the FLV file from becoming bigger then it originally was. With this disabled it will expand to fit the size of the player. The video length can be left at zero. The URL can be set to hardcode in a video, or it can be left blank and in the next steps we will make it dynamic.

component inspector

Step 5. In order to use the same swf file to play a number of different videos we will make the URL dynamic. Add this code to the first keyframe of your document.

player.contentPath = file;

Then add these to your Flash HTML code.

<param name=”FlashVars” value=”file=myvideo.flv”/>

and the same to the embed tag

FlashVars=”file=myvideo.flv”

A simple variation for PHP would be to set it to a parameter variable so that it could be called with

/video.php?video=myvideo.flv

by adding some simple PHP code

FlashVars=”file=<? print($_GET["video"]); ?>”

flv player

You should now have a fully working FLV player that takes a file name from the HTML or URL and loads it into the player.

10 Responses to “Creating a Web FLV Player”

  1. Aaron Says:

    Dude. You are AWESOME. I’ve been looking all over for this answer, and you had exactly what I needed. Thankyousomuch! :D

  2. Moses N Says:

    Its been a horrendous experience getting to find this piece of information and its worth all the searches i have done on the net. Cheers!

  3. Hough Says:

    I need the same, but without php code.
    Can i do it but with javascript or with simple html.

    I only want a swf than i can use it with all of my .flv (only a flv player).

    Because now i have to make a swf for each flv and if i want to change the desgin of my swf, i have to change all my old swf. Buf!!

    please help me if you can!!

  4. JT Says:

    Thanks for the info. Is there a way to customize the media controls?
    JT

  5. lucius Says:

    you can drop in just the screen part of the player and make your own controls. I haven’t tried making my own so I can’t help you there unfortunately.

  6. eric Says:

    does anyone have a working example of this?

  7. tarun Says:

    I have problem in this flv player. its not run properly.

  8. tarun Says:

    any one can send me source file for this flv player.

  9. tarun Says:

    Hi,

    Its good but i want to add some custom controller. Please tell me how can i do this.

  10. kupruk Says:

    can anyone put the source file for download?

Leave a Reply