Files
ohmj2/Scripts/Video.php
2009-09-15 21:08:20 +00:00

114 lines
4.0 KiB
PHP

<?php
/***************************************************************************
Video.php - Class to play flv video.
-------------------
begin : 12 Mai UTC 2008
copyright : (C) 2008 by NADAL Jean-Baptiste
email : jbnadal@ifrance.com
***************************************************************************
*
* Cette classe permet de visualiser les videos presentent dans le
* repertoire 'video' du site grave au player flash.
*
***************************************************************************
* *
* 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. *
* *
***************************************************************************/
if (file_exists("conf.php")) {
require("conf.php");
}
else {
require("./Scripts/conf.php");
}
class VideoEntries
{
/* Member variables. */
var $root;
var $videoDir;
var $width;
var $height;
/* ============================================================= */
/* Constructeur */
function VideoEntries ($aRoot, $aVideoDir)
{
$this->root = $aRoot;
$this->videoDir = $aVideoDir;
$this->width = 320;
$this->height = 240;
}
/* This function display All the video present on the video directory. */
function Affiche ()
{
$rootDir = $this->root . $this->videoDir;
$id = 0;
$col = 1;
if ($dh = opendir ($rootDir)) {
print "<center><table border=\"0\" cellspacing=\"8\"><tr>\n";
while (($file = readdir($dh)) !== false) {
$videoFile = strstr ($file, "flv");
$videoFileLen = strlen ($videoFile);
if ($videoFileLen != 0) {
echo "<td valign=\"top\"><center>";
$this->DisplayVideo ($id, "../".$file,
$this->width, $this->height);
echo "</center><br/>\n";
$FileName = explode( ".", $file);
$docFileName = $rootDir . $FileName[0] . ".html";
$pFichier = @fopen ($docFileName,"r");
if ($pFichier == false) {
echo "</br></br>";
}
else {
while ( feof($pFichier) != 1 ) {
$szLigne = fgets($pFichier);
echo "<center>".$szLigne."</center></br>";
}
}
echo "</td>";
$id += 1;
$col = $col + 1;
if ($col == 3) {
print "</tr><tr>\n";
$col = 1;
}
}
}
if (col == 1) {
print "/<tr>";
}
print "</table></center>\n";
}
closedir($dh);
}
/* This function display the video with the flash video player. */
function DisplayVideo ($id, $aFileName, $width, $height)
{
echo "<div id=\"container".$id."\">
<a href=\"http://www.macromedia.com/go/getflashplayer\">Get the Flash Player</a> to see this player.
</div>\n";
echo "<script type=\"text/javascript\" src=\"./videos/bin/swfobject.js\"></script>\n";
echo "<script type=\"text/javascript\">\n
var s1 = new SWFObject(\"./videos/bin/mediaplayer.swf\",
\"mediaplayer\",\"".$width."\",\"".
$height."\",\"8\");\n
s1.addParam(\"allowfullscreen\",\"true\");\n
s1.addVariable(\"width\",\"".$width."\");\n
s1.addVariable(\"height\",\"".$height."\");\n
s1.addVariable(\"file\",\"".$aFileName."\");\n
s1.write(\"container".$id."\");\n
</script>\n";
}
}
?>