|
12/23/2007: Minor update, fixed a couple bugs.
The Add-On pack provides some awesome utility functions to use the Open Source FLV player with PHP. Whats in the add-on pack?
- demo.php - A file that shows the new flv functions.
- player.swf - The FLV player for Flash player 9. If you want the support for Flash player 8, just paste that swf over this one. You'll loose full screen mode.
- rac.js - A heavily compressed version of AC_RunActiveContent.js*
- video.flv - A test video. Its me beating level one of Staggy the Boyscout Slayer II.
- flash/ - PHP functions for the FLV player.
The Add-On pack makes it extremely easy to add the FLV player to a PHP page. In fact, it only takes three lines!
<?php include ('flash/flash.php'); ?>
<script charset="ISO-8859-1" src="rac.js" language="javascript"></script>
<?php flv('video.flv'); ?>
This method automatically sets the player to the dimensions of the flv. It works with or without javascript, does not display the "Click to activate this control" message in internet explorer, and shaves 6kb off the js file provided in CS3.
The header for the flv function is:
function flv($movie, $width=-1, $height=-1, $autoplay=false)
So, to match the dimensions of the movie, you just need to call flv('mymovie.flv'). To set the height and width, the call would look like flv('mymovie.flv', 300, 200). To set the height and width, and make the movie autoplay, the call would be flv('mymovie.flv', 300, 200, true), and to match the dimensions of the flv file, and have it autoplay, the call would be flv('mymovie.flv', -1, -1, true).
There are two other useful functions in the library.
function getflvsize($movie)
This function takes in the path to an flv file, and returns an array with the width and height. This is really just a wrapper for the getID3 class, and can easily be modified to return more information.
The second function is just a simple swf embed.
function embed($swf, $width, $height, $flashvars='')
Again this can be modified as needed, and greatly shortens the code needed to properly embed an swf file.
The Add-On PHP library uses getID3 by James Heinrich to read in the FLV file size.
Coming Soon:- Automatic switching between Flash 9 and Flash 8 versions of the player
*Compression Provided by ScriptDiet, a very useful utility.
|