Welcome, Guest. Please login or register.
Did you miss your activation email?
06 Oct 2008, 10:40

Login with username, password and session length
Home Chat Help Search Calendar Login Register
Pages: [1] 2 3
Print
Author Topic: flv -buggy- player  (Read 64374 times)
0 Members and 2 Guests are viewing this topic.
chris..
Forum Member
*

Karma: 5
Offline Offline

Posts: 49


« on: 08 Jun 2006, 18:23 »

I wrote an I-m-sure-full-of-bugs tag to embed a flv player into CMSMS. If someone is interesting to make it a complete module with comments and so on, here is a basic step to begin.
I'm nOOb with php (just copy/paste master), so : the first letter of the file name called in the array is missing (I'm tired of coding and full of wine)  and maybe this tag only works when everything is in the right directory (uploads/videos). When I say everything, I mean .flv files (your work) and the flvplayer.swf (found here : http://www.jeroenwijering.com/upload/flash_flv_player.zip ). Check out the help file for license and original author.

The cool part of this tag is the automatic listing of .flv files.

the tag : {flvplayer}

and the code (save it as function.flvplayer.php into plugins/) :
Code:
<?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 "uploads/videos";
$width "360";
$height "288";
$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'];

// autoscanning the flv directory
@$flv_d dir($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 strrpos($flv_files[$flv_file-1],"/") + 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 .= '<h1>'.$flv_name.'</h1><br />'."\n";
$result .= '<div id="flvplayer">'."\n";
$result .= '<object type="application/x-shockwave-flash" data="'.$dir.'/flvplayer.swf?file='.$flv_files[$flv_file-1].'" width="'.$width.'" height="'.$height.'" wmode="transparent">'."\n";
$result .= '<param name="movie" value="'.$dir.'/flvplayer.swf?file='.$flv_files[$flv_file-1].'" />'."\n";
$result .= '<param name="wmode" value="transparent" />'."\n";
  
$result .= '</object>'."\n";
$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 strrpos($flv_files[$flv_i],"/") + 1;
$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>
  </ul>
  </p>
  <?php
}


function 
smarty_cms_about_function_flvplayer() 
{
?>

  <p>Author:  chris.. &lt;chris@poegraphie.net&gt;</p>
  <p>Version -buggy- 0.1</p>
<?php
}

?>
Logged
chris..
Forum Member
*

Karma: 5
Offline Offline

Posts: 49


« Reply #1 on: 09 Jun 2006, 13:32 »

I've made some corrections and it seems to work better. Just put your .flv files and the player (read the first post)  in the same directory (call it whatever you want, default is "videos") and just put {flvplayer dir="whatever you want"} in some content page.

I have to make the layout a lil'bit more graphic, but the tag is still in its 0.1 version  Wink

Here is the less buggy code:
Code:
<?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";
$width "360";
$height "288";
$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'];

$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 .= '<h1>'.$flv_name.'</h1><br />'."\n";
$result .= '<div id="flvplayer">'."\n";
$result .= '<object type="application/x-shockwave-flash" data="'.$flv_dir.'/flvplayer.swf?file='.$flv_files[$flv_file-1].'" width="'.$width.'" height="'.$height.'" wmode="transparent">'."\n";
$result .= '<param name="movie" value="'.$flv_dir.'/flvplayer.swf?file='.$flv_files[$flv_file-1].'" />'."\n";
$result .= '<param name="wmode" value="transparent" />'."\n";
  
$result .= '</object>'."\n";
$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>
  </ul>
  </p>
  <?php
}


function 
smarty_cms_about_function_flvplayer() 
{
?>

  <p>Author:  chris.. &lt;chris@poegraphie.net&gt;</p>
  <p>Version -buggy- 0.1</p>
<?php
}

?>

Logged
tsw
Administrator
Power Poster
*****

Karma: 49
Offline Offline

Posts: 1415

Location: Finland


« Reply #2 on: 09 Jun 2006, 15:30 »

nice to see these things..

you could however register new project for this so you can use svn for updates.
Logged
chris..
Forum Member
*

Karma: 5
Offline Offline

Posts: 49


« Reply #3 on: 09 Jun 2006, 17:49 »

I'm realy new to CMSMS and actualy to forums too (and coding php), I've got one star, you get five, so, tell me the road to do what you're talking about. I've already made some changes and svn is clearely a better way than posting the entire code a thousands times here.
I'm glad this tag is pleasing you -is that english? stop me if not- but I think it has to be re-written for CMSMS (with smarty codes, or other things I do not even know).
Everyone is welcome to contribute to it.
Logged
tsw
Administrator
Power Poster
*****

Karma: 49
Offline Offline

Posts: 1415

Location: Finland


« Reply #4 on: 10 Jun 2006, 04:28 »

I'm realy new to CMSMS and actualy to forums too (and coding php), I've got one star, you get five, so, tell me the road to do what you're talking about.

You are more than welcome in the land of cmsms Smiley

Actually I think that one of the best ways to learn these things is by doing.

I've already made some changes and svn is clearely a better way than posting the entire code a thousands times here.

Yes its much more simpler.

Go into forge (http://dev.cmsmadesimple.org/) and register your self, then register a new project. after its approved you get admin status for that project. there are some documentation about svn in wiki and search these forums for info about svn clients (if you are on linux machine it most probably already has a client, just try svn checkout url...)

or as this is just one file you can create new wiki page for it. (one place I can think that fits for something like this is http://wiki.cmsmadesimple.org/index.php/Share_your_tags_here) you can login with your forum user/pass

I'm glad this tag is pleasing you -is that english? stop me if not- but I think it has to be re-written for CMSMS (with smarty codes, or other things I do not even know).
Everyone is welcome to contribute to it.

Everything that drives this project forward is good Smiley

actually we lack something like this from the core, I havent yet tested this tag, but have written similar plugin for a friend Smiley
Logged
mark
Available for Consults
Support Guru
Power Poster
****

Karma: 125
Offline Offline

Posts: 5758

Location: Arizona


Keepin an eye out for you...


WWW
« Reply #5 on: 05 Jul 2006, 20:06 »

do you have a working model we can see?
Logged

Go to Extensions Modules/Tags click the name of the module/tag or the word Help to the right to get the parameters it takes...
Not sure what ver. CMSMS, PHP, server OS, etc. try the Support Tool in your page...
CMSMS hosting available now, with installation, let me know if your interested...

WHY oh why, can anyone tell me, does it seem like no one reads all the pages that come with a default install.

OK if you removed the default content read it here... http://multiintech.com/default/
chris..
Forum Member
*

Karma: 5
Offline Offline

Posts: 49


« Reply #6 on: 09 Jul 2006, 07:04 »

Not online anymore, but the player looks like this : http://www.jeroenwijering.com/?item=Flash_Video_Player , with a list of your video files. I've made a screenshot on my local site (see attachment).

[attachment deleted by admin]
Logged
MichaelK
Forum Member
*

Karma: 1
Offline Offline

Posts: 146

Location: The Netherlands



« Reply #7 on: 09 Jul 2006, 12:38 »

Hi there,


When I click on the text link for the next video, nothing shows up. I get an 404 error.

How can I fix this?
Logged
chris..
Forum Member
*

Karma: 5
Offline Offline

Posts: 49


« Reply #8 on: 10 Jul 2006, 01:59 »

Try to name your .flv files without special chars (first : try names as simple as possible).
Did you put all your files in the same dir (flvplayer + .flv files), a directory named "videos" (or whatever but then tell it in your tag {flvplayer dir='my_video_directory'} )? This dir must be placed in your "CMSMS/uploads/"
Sorry, I'm actualy not a developper as I said, I made it for fun  Wink
Logged
MichaelK
Forum Member
*

Karma: 1
Offline Offline

Posts: 146

Location: The Netherlands



« Reply #9 on: 10 Jul 2006, 06:52 »

I did all these things but It won't help.

When I wanna play the next video file I get this URL:
video?page=&file=1 with an 404 error.

Any idea? Huh
Logged
chris..
Forum Member
*

Karma: 5
Offline Offline

Posts: 49


« Reply #10 on: 10 Jul 2006, 12:07 »

The only wrong thing I see is the "page=" with nothing behind. What's the name of your page (does it have an alias) ?
You should have something like "index.php?page=test/&file=1"
Logged
MichaelK
Forum Member
*

Karma: 1
Offline Offline

Posts: 146

Location: The Netherlands



« Reply #11 on: 08 Nov 2006, 13:46 »

There's a brand new version of FLV Player.

http://www.jeroenwijering.com/?item=Flash_Video_Player

Anyone that can update the function.flvplayer.php?

New futures:
Fullscreen
Playback, Forward
Time notation etc etc...
Logged
westis
Dev Team Member
Power Poster
*****

Karma: 7
Offline Offline

Posts: 650

Location: Vxj, Sweden


« Reply #12 on: 01 Dec 2006, 13:57 »

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).

Code:
<?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">'