Hopefully, the last FLV player I'll ever code
ActionScript Ruby
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets
com/bomberstudios
script
.gitignore
LICENSE
README.mdown
Rakefile
app.rb
config.yml
flvplayer.as
flvplayer.rxml
index.rhtml

README.mdown

flvplayer

flvplayer is a FLV player, built in ActionScript.

The main goals of the project are:

  • have a functional player with a proper open source license (MIT)
  • being able to compile the player using only Open Source tools (MTASC, swfmill, Ruby)
  • have a simple codebase that can be used on a more complex project

Usage

Embedding

<script type="text/javascript" src="/swfobject.js"></script>
<div id="flashcontent">
  This text is replaced by the Flash movie.
</div>
<script type="text/javascript">
  var so = new SWFObject("flvplayer.swf", "flvplayer", "640", "360", "8", "#000000");
  so.addParam('allowFullScreen',true); // this is needed if you want fullscreen video playing
  so.addVariable('aspect_ratio',16/9);
  so.addVariable('placeholder','placeholder.jpg');
  so.addVariable('video_path','video.flv');
  so.write("flashcontent");
</script>

Setup

You can use the following variables in your HTML (* are required):

video_path*

so.addVariable('video_path','video.flv');

String. URL to the FLV video you want to play. It can be relative ('/video/test.flv') or absolute ('http://site.com/video/test.flv)

placeholder

so.addVariable('placeholder','placeholder.jpg');

String. URL to the image you want to display as a placeholder. It is displayed before the video plays, and after it ends.

autoplay

so.addVariable('autoplay');

Makes the video play automatically when the SWF is loaded.

aspect_ratio

so.addVariable('aspect_ratio',16/9);

Number. Default aspect ratio to be used for your movie. By default it's 16/9, but if the FLV contains width and height metadata it will be used for auto aspect_ratio calculation.

watermark

so.addVariable('watermark','logo.png');

String. URL to an image to be displayed on top of the video (like a TV station logo, for example).

The position can be specified by using the 'watermarkPosition' variable:

so.addVariable('watermarkPosition',position);

where 'position' is a string with a value of TL, TR, BL or BR (for Top Left, Top Right, Bottom Left or Bottom Right). If you don't specify anything, the default position is BR (Bottom Right).

has_streaming

so.addVariable('has_streaming');

Enable pseudostreaming support.

Whenever the user tries to watch a segment that is not loaded yet, the player will make a request to the server, with this format:

http://path.to.video.file.flv?start=XXXXXXXX

fullscreen

so.addVariable('fullscreen');
so.addParam('allowFullScreen',true);

Enable the fullscreen button.

stealth_mode

so.addVariable('stealth_mode');

When this option is set, the controls are not displayed by default.

FLV Streaming

The player supports FLV pseudostreaming. It is disable by default.

Take a look at the sample sinatra app (app.rb) to see how it works.

The sinatra app requires the 'rack-contrib' gem, so install it with:

$ gem install rack-contrib

To use pseudostreaming in your FLV files, they need to contain some metadata. You can embed this metadata by using flvtool2:

$ sudo gem install flvtool2
$ flvtool2 -U your_video_file.flv

NOTE: Don't even think of running the sinatra app in a production environment. Use a real webserver and take a look at these articles:

Compilation

flvplayer has been created using fluby, so compilation is pretty straightforward:

 $ cd flvplayer
 $ rake

There are some additional rake tasks available:

  • rake clobber_package # Remove package products
  • rake package # Build all the packages
  • rake release # Build a release version of flvplayer (with trace() disabled)
  • rake repackage # Force a rebuild of the package files
  • rake test # Test the SWF file in your default browser

Customization

All images used in the player are available inside the 'assets' folder, in Fireworks CS3 vector format.

If you want to change the look & feel of your player, just edit the PNG files and recompile.

LICENSE

flvplayer is released under the MIT License. Feel free to use the software as you please, but it would be nice if you shared your improvements even if it's not required :)

Copyright (c) 2009 Ale Muñoz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.