I updated the plugin to be used with the latest version of FLV Player (3.1). Also added a few more parameters. It's using a JavaScript that is part of the package that you have to download from
http://www.jeroenwijering.com/?item=Flash_Video_Player (and upload to any directory on your server, but the same directory as the flvplayer.swf file).
I also added a few more parameters that can be used with FLV Player 3.1 (there are more parameters available too, but maybe this could be turned into a module instead at some point).
showdigits: Set this to true to show the digits for % loaded, elapsed and remaining time in the flvplayer. (default : true)
showfsbutton: Set this to true to show the fullscreen button. (default : true)
autostart: Set this to "true" if you want the flvplayer to automatically start playing. (default : false)
playerdir: The directory where flvplayer.swf is found. (defaults to root dir)
fullscreenpage: HTML page to jump to for fullscreen. This HTML page has the flvplayer included at 100% screensize. (default : fullscreen.html)
Here's the tag (save as function.flvplayer.php) and upload to the /plugins folder. Use it in a page or template with the {flvplayer} tag (and optional parameters).
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
function smarty_cms_function_flvplayer($params, &$smarty) {
$dir = "videos";
$playerdir = "";
$width = "360";
$height = "288";
$showdigits = "true";
$showfsbutton = "true";
$autostart = "false";
$fullscreenpage = "fullscreen.html";
$fsreturnpage = "filmtest";
$flv_selfA = explode('/', $_SERVER["PHP_SELF"]);
$flv_self = $flv_selfA[sizeOf($flv_selfA)-1] . '?page=' . $_GET['page'];
if(!empty($params['dir']))
$dir = $params['dir'];
if(!empty($params['width']))
$width = $params['width'];
if(!empty($params['height']))
$height = $params['height'];
if(!empty($params['showdigits']))
$showdigits = $params['showdigits'];
if(!empty($params['showfsbutton']))
$showfsbutton = $params['showfsbutton'];
if(!empty($params['autostart']))
$autostart = $params['autostart'];
if(!empty($params['playerdir']))
$playerdir = $params['playerdir'];
$playerdir = preg_replace("/(\/|\\\)++/","",$playerdir);
if(!empty($params['fullscreenpage']))
$fullscreenpage = $params['fullscreenpage'];
$flv_dir = "uploads/".$dir;
// autoscanning the flv directory
@$flv_d = dir($flv_dir);
if ($flv_d) {
while($flv_entry=$flv_d->read()) {
$flv_entry = preg_replace("/ /","%20",$flv_entry);
$flv_pos = strpos(strtolower($flv_entry), ".flv");
if (!($flv_pos === false)) {
$flv_files[] = $flv_entry;
}
}
$flv_d->close();
}
// getting the file from the url
if ($_GET['file']) { $flv_file = $_GET['file']; } else { $flv_file = 1; }
// extracting the name of the video
$flv_p1 = strpos($flv_files[$flv_file-1],"/");
$flv_p2 = strpos($flv_files[$flv_file-1],".flv");
$flv_name = substr($flv_files[$flv_file-1],$flv_p1,($flv_p2-$flv_p1));
// Showed in content
$result .= '<script type="text/javascript" src="'$playerdir.'ufo.js"></script>'."\n";
$result .= '<h1>'.$flv_name.'</h1><br />'."\n";
$result .= '<div id="flvplayer">'."\n";
$result .= '<p id="player1"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p>'."\n";
$result .= '<script type="text/javascript">'."\n";
$result .= ' var FO = { movie:"'.$playerdir.'/flvplayer.swf",width:"'.$width.'",height:"'.$height.'",majorversion:"7",build:"0",bgcolor:"#FFFFFF",'."\n";
$result .= ' flashvars:"file='.$flv_files[$flv_file-1].'&showdigits='.$showdigits.'&autostart='.$autostart.'&showfsbutton='.$showfsbutton.'&fullscreenpage='.$fullscreenpage.'" };'."\n";
$result .= ' UFO.create(FO,"player1");';
$result .= ' </script>';
$result .= '</div>'."\n";
$result .= '<div id="flvarray">'."\n";
$result .= '<ul>'."\n";
for ($flv_i=0; $flv_i<=sizeof($flv_files)-1; $flv_i++) {
$flv_p1 = strpos($flv_files[$flv_i],"/");
$flv_p2 = strpos($flv_files[$flv_i],".flv");
$flv_name = substr($flv_files[$flv_i],$flv_p1,($flv_p2-$flv_p1));
$result .= '<li><a href="'.$flv_self.'&file='.($flv_i+1).'">'.$flv_name.'</a></li>'."\n";
}
$result .= '</ul>'."\n";
$result .= '</div>'."\n";
return $result;
}
function smarty_cms_help_function_flvplayer()
{
?>
<h3>IMPORTANT !!!</h3>
<p>the flvplayer.swf file must be stored in the directory with .flv files</p>
<p>you have to download it from <a href="http://www.jeroenwijering.com/?item=Flash_Video_Player">here</a> (with .fla sources)</p>
<p>This script is licensed under a <a href="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons License </a>by his original <a href="mailto:mail@jeroenwijering.com">author</a></p>
<h3>What does this do?</h3>
<p>Creates an flv (flash video) player with automatic listing of stored files</p>
<h3>How do I use it?</h3>
<p>Just insert the tag into your template/page like: <code>{flvplayer}</code><em> (Can it be more simple ?)</em></p>
<h3>What parameters does it take?</h3>
<p>
<ul>
<li><em>(optional)</em> <tt>dir</tt> - path from root/uploads (whitout end "/") where .flv files and flvplayer.swf are stored (default : videos)</li>
<li><em>(optional)</em> <tt>width</tt> - Width of the video (default : 360)</li>
<li><em>(optional)</em> <tt>height</tt> - Height of the video (default : 288)</li>
<li><em>(optional)</em> <tt>showdigits</tt> - Set this to true to show the digits for % loaded, elapsed and remaining time in the flvplayer. (default : true)</li>
<li><em>(optional)</em> <tt>showfsbutton</tt> - Set this to true to show the fullscreen button. (default : true)</li>
<li><em>(optional)</em> <tt>autostart</tt> - Set this to "true" if you want the flvplayer to automatically start playing. (default : false)</li>
<li><em>(optional)</em> <tt>playerdir</tt> - The directory where flvplayer.swf is found. (defaults to root dir)</li>
<li><em>(optional)</em> <tt>fullscreenpage</tt> - HTML page to jump to for fullscreen. This HTML page has the flvplayer included at 100% screensize. (default : fullscreen.html)</li>
</ul>
</p>
<?php
}
function smarty_cms_about_function_flvplayer()
{
?>
<p>Author: chris.. <chris@poegraphie.net></p>
<p>Version -buggy- 0.1</p>
<p>Version 0.2 - Updated to FLV PLayer 3.1 and five more parameters added (Daniel Westergren)</p>
<?php
}
?>
Still a lot more could be done to this plugin. For example there is an option to use a playlist with the latest FLVPlayer. Also, if this is turned into a module more info about each video file could be added to the database, like description, preview thumbnail etc.
But this is a good start.
