-
AuthorPosts
-
gaygiorgia Friend
gaygiorgia
- Join date:
- June 2008
- Posts:
- 218
- Downloads:
- 0
- Uploads:
- 7
- Thanks:
- 15
- Thanked:
- 15 times in 1 posts
June 24, 2008 at 5:23 am #130061I thougt: all videos by fritz is very very good, why don’t develop playlist code by ja too (and get it more professional)?
So i started to found needings of a Real Magazine Portal:1) the playlist should read files from their presencein a folder (ja playlist code already does it);
MORE NEEDINGS (because videos/audios are contents like articles and has same needings):
2) the playlist should always read last inserted files;
3) the playlist should ordinate files by their data creation and not by their names;
4) the playlist should let show only a part of files stored in the folder at point 1.I’ve solved only point 2) -because i’m not a coder- (by naming files with progressive number prefix and with a php command) , but i’m sure we can solve points 3) and 4) too.
ORIGINAL JA PLAYLIST CODE:
<?php
define('DS', DIRECTORY_SEPARATOR);
$folder = (isset($_REQUEST['folder'])) ? $_REQUEST['folder'] : "";
$thumbfolder = ($folder) ? $folder."/" : "";
function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS', 'php'), $include = array('flv','mp4','swf','3gp','mp3','rbs'))
{
// Initialize variables
$arr = array ();// Is the path a folder?
if (!is_dir($path)) {
?>
<script language="javascript" type="text/javascript">alert('Path is not a folder <?php echo $path; ?>'); </script>
<?php
return false;
}// read the source directory
$handle = opendir($path);
while (($file = readdir($handle)) !== false)
{
$dir = $path.DS.$file;
$isDir = is_dir($dir);
if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) {
if ($isDir) {
if ($recurse) {
if (is_integer($recurse)) {
$recurse--;
}
$arr2 = files($dir, $filter, $recurse, $fullpath);
$arr = array_merge($arr, $arr2);
}
} else {if (preg_match("/$filter/", $file)) {
$path_parts = pathinfo($path.DS.$file);
if(in_array($path_parts['extension'], $include)){
if ($fullpath) {
$arr[] = $path.DS.$file;
} else {
$arr[] = $file;
}
}
}
}
}
}
//closedir($handle);//asort($arr);
return $arr;
}
$path = dirname(__FILE__);
$files = files($path.DS.$folder);$url = dirname($_SERVER['REQUEST_URI']);
?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>CG Playlist</title>
<trackList>
<?php
foreach($files as $f){
if(file_exists($path.DS.$folder.DS."thumbnail".DS.$f.".jpg")){
$img = "$url/{$thumbfolder}thumbnail/$f.jpg";
}elseif(file_exists($path.DS.$folder.DS."thumbnail".DS.$f.".gif")){
$img = "$url/{$thumbfolder}thumbnail/$f.gif";
} else $img = "";
?>
<track>
<title><?php echo $f; ?></title>
<location><?php echo "$url/$folder/$f";?></location>
<image><?php echo $img; ?></image>
</track>
<?php
}
?>
</trackList>
</playlist>i added the row: “rsort($files);” so code becomes:
<?php
define('DS', DIRECTORY_SEPARATOR);
$folder = (isset($_REQUEST['folder'])) ? $_REQUEST['folder'] : "";
$thumbfolder = ($folder) ? $folder."/" : "";
function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS', 'php'), $include = array('flv','mp4','swf','3gp','mp3','rbs'))
{
// Initialize variables
$arr = array ();// Is the path a folder?
if (!is_dir($path)) {
?>
<script language="javascript" type="text/javascript">alert('Path is not a folder <?php echo $path; ?>'); </script>
<?php
return false;
}// read the source directory
$handle = opendir($path);
while (($file = readdir($handle)) !== false)
{
$dir = $path.DS.$file;
$isDir = is_dir($dir);
if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) {
if ($isDir) {
if ($recurse) {
if (is_integer($recurse)) {
$recurse--;
}
$arr2 = files($dir, $filter, $recurse, $fullpath);
$arr = array_merge($arr, $arr2);
}
} else {if (preg_match("/$filter/", $file)) {
$path_parts = pathinfo($path.DS.$file);
if(in_array($path_parts['extension'], $include)){
if ($fullpath) {
$arr[] = $path.DS.$file;
} else {
$arr[] = $file;
}
}
}
}
}
}
//closedir($handle);//asort($arr);
return $arr;
}
$path = dirname(__FILE__);
$files = files($path.DS.$folder);$url = dirname($_SERVER['REQUEST_URI']);
?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>CG Playlist</title>
<trackList>
<?php
rsort($files);
foreach($files as $f){
if(file_exists($path.DS.$folder.DS."thumbnail".DS.$f.".jpg")){
$img = "$url/{$thumbfolder}thumbnail/$f.jpg";
}elseif(file_exists($path.DS.$folder.DS."thumbnail".DS.$f.".gif")){
$img = "$url/{$thumbfolder}thumbnail/$f.gif";
} else $img = "";
?>
<track>
<title><?php echo $f; ?></title>
<location><?php echo "$url/$folder/$f";?></location>
<image><?php echo $img; ?></image>
</track>
<?php
}
?>
</trackList>
</playlist>so, before if i have 3 videos: 1_namevideo1, 2_namevideo2, 3_namevideo3 playlist was:
1_namevideo1
2_namevideo2
3_namevideo3if i add a new video and name it 4_namevideo4, playlist becomes:
1_namevideo1
2_namevideo2
3_namevideo3
4_namevideo4Now, instead, with rsort($files); playlist is:
4_namevideo4
3_namevideo3
2_namevideo2
1_namevideo1Solving point 3) will eliminate the progressive number prefix need.
if there is som1 who is php coder pls could help us to implement these improvements π
================================
WATCH HERE FOR FINAL WORKING CODE
================================π
June 24, 2008 at 8:40 pm #255900Hi,
It would also be a very good idea to have the play list longer than just showing 2 titles.
The scroll bar to the right is very anonymous.I guess that is as easy code, but I’m not that good at php π
gaygiorgia Friendgaygiorgia
- Join date:
- June 2008
- Posts:
- 218
- Downloads:
- 0
- Uploads:
- 7
- Thanks:
- 15
- Thanked:
- 15 times in 1 posts
June 25, 2008 at 6:05 am #256008<em>@hdfilm 61837 wrote:</em><blockquote>Hi,
It would also be a very good idea to have the play list longer than just showing 2 titles.
The scroll bar to the right is very anonymous.I guess that is as easy code, but I’m not that good at php :)</blockquote>
playlist longer? wtf?
i’m not speaking about longer playlist… I’m not speaking of playlist height in module…if u want a longer playlist change height value in the original code
{auto height="300" displayheight="235"}playlist.php{/auto}
for example with:
{auto height="400" displayheight="235"}playlist.php{/auto}
i’m speaking of more professional playlist code.
it’s a different think. πJune 25, 2008 at 9:35 am #256066I know that you didn’t talk about longer play list. I did not say that you were talking about it.
It was my wish and thought only.But thank you for letting med know where the code for the height adjustment π
gaygiorgia Friendgaygiorgia
- Join date:
- June 2008
- Posts:
- 218
- Downloads:
- 0
- Uploads:
- 7
- Thanks:
- 15
- Thanked:
- 15 times in 1 posts
June 25, 2008 at 10:09 am #256074<em>@hdfilm 62025 wrote:</em><blockquote>I know that you didn’t talk about longer play list. I did not say that you were talking about it.
It was my wish and thought only.But thank you for letting med know where the code for the height adjustment :)</blockquote>
oh by reading better your post, u right… i missed “also” ^^.happy to be usefull π
Sherlock FriendSherlock
- Join date:
- September 2014
- Posts:
- 11453
- Downloads:
- 0
- Uploads:
- 88
- Thanks:
- 221
- Thanked:
- 2478 times in 2162 posts
June 26, 2008 at 6:53 am #256311HI gaygiorgia
Thank for sharing
Can I mark this topic is solved ?gaygiorgia Friendgaygiorgia
- Join date:
- June 2008
- Posts:
- 218
- Downloads:
- 0
- Uploads:
- 7
- Thanks:
- 15
- Thanked:
- 15 times in 1 posts
June 26, 2008 at 9:39 am #256379<em>@nguoiabcd 62315 wrote:</em><blockquote>HI gaygiorgia
Thank for sharing
Can I mark this topic is solved ?</blockquote>
hi dear,
if u let me, pls give me some days more: i’m working on php code to obtain a new code with features explained at points 3) and 4) at the 1st post.
When i’ll have a working solution, i’ll post the modified new code πgaygiorgia Friendgaygiorgia
- Join date:
- June 2008
- Posts:
- 218
- Downloads:
- 0
- Uploads:
- 7
- Thanks:
- 15
- Thanked:
- 15 times in 1 posts
June 27, 2008 at 6:49 am #256618Ok, i’ve finished π
pls, sticky it if u find it usefull π1) Original Joomlart.com code:
features:
a) it shown all files in the playlist.php folder by their crescent alphabetical order<?php
define('DS', DIRECTORY_SEPARATOR);
$folder = (isset($_REQUEST['folder'])) ? $_REQUEST['folder'] : "";
$thumbfolder = ($folder) ? $folder."/" : "";
function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS', 'php'), $include = array('flv','mp4','swf','3gp','mp3','rbs'))
{
// Initialize variables
$arr = array ();// Is the path a folder?
if (!is_dir($path)) {
?>
<script language="javascript" type="text/javascript">alert('Path is not a folder <?php echo $path; ?>'); </script>
<?php
return false;
}// read the source directory
$handle = opendir($path);
while (($file = readdir($handle)) !== false)
{
$dir = $path.DS.$file;
$isDir = is_dir($dir);
if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) {
if ($isDir) {
if ($recurse) {
if (is_integer($recurse)) {
$recurse--;
}
$arr2 = files($dir, $filter, $recurse, $fullpath);
$arr = array_merge($arr, $arr2);
}
} else {if (preg_match("/$filter/", $file)) {
$path_parts = pathinfo($path.DS.$file);
if(in_array($path_parts['extension'], $include)){
if ($fullpath) {
$arr[] = $path.DS.$file;
} else {
$arr[] = $file;
}
}
}
}
}
}
//closedir($handle);//asort($arr);
return $arr;
}
$path = dirname(__FILE__);
$files = files($path.DS.$folder);$url = dirname($_SERVER['REQUEST_URI']);
?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>CG Playlist</title>
<trackList>
<?php
rsort($files);
foreach($files as $f){
if(file_exists($path.DS.$folder.DS."thumbnail".DS.$f.".jpg")){
$img = "$url/{$thumbfolder}thumbnail/$f.jpg";
}elseif(file_exists($path.DS.$folder.DS."thumbnail".DS.$f.".gif")){
$img = "$url/{$thumbfolder}thumbnail/$f.gif";
} else $img = "";
?>
<track>
<title><?php echo $f; ?></title>
<location><?php echo "$url/$folder/$f";?></location>
<image><?php echo $img; ?></image>
</track>
<?php
}
?>
</trackList>
</playlist>2) MODIFIED PLAYLIST.PHP CODE v1:
features:
a) files are no more ordinated by their names, but by their last modification/ their last creation date;
b) it only shows last “$tot” files created/modificated (in this case 5 files). To change number of files showed, you have to change $tot value.<?php
define('DS', DIRECTORY_SEPARATOR);
$folder = (isset($_REQUEST['folder'])) ? $_REQUEST['folder'] : "";
$thumbfolder = ($folder) ? $folder."/" : "";//* Con questa funzione i files si ordinano in base alla loro data di creazione/ultima modifica *//
//* With this function files are ordinated by their creation date/last modification *//function ordina( $file1, $file2 )
{
$tempo1 = filectime($file1);
$tempo2 = filectime($file2);
return ($tempo1 < $tempo2) ? 1 : -1;
}function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS', 'php'), $include = array('flv','mp4','swf','3gp','mp3','rbs'))
{
// Initialize variables
$arr = array ();// Is the path a folder?
if (!is_dir($path)) {
?>
<script language="javascript" type="text/javascript">alert('Path is not a folder <?php echo $path; ?>'); </script>
<?php
return false;
}// read the source directory
$handle = opendir($path);
while (($file = readdir($handle)) !== false)
{
$dir = $path.DS.$file;
$isDir = is_dir($dir);
if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) {
if ($isDir) {
if ($recurse) {
if (is_integer($recurse)) {
$recurse--;
}
$arr2 = files($dir, $filter, $recurse, $fullpath);
$arr = array_merge($arr, $arr2);
}
} else {if (preg_match("/$filter/", $file)) {
$path_parts = pathinfo($path.DS.$file);
if(in_array($path_parts['extension'], $include)){
if ($fullpath) {
$arr[] = $path.DS.$file;
} else {
$arr[] = $file;
}
}
}
}
}
}
//closedir($handle);//asort($arr);
return $arr;
}
$path = dirname(__FILE__);
$files = files($path.DS.$folder);$url = dirname($_SERVER['REQUEST_URI']);
?><playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>CG Playlist</title>
<trackList>
<?php$test = array();
$test2 = $path.DS.$folder;
for( $c = 0; $c < sizeof($files); $c++)
{
$test[] = $test2 . $files[$c];
}
usort($test,'ordina');for( $c = 0; $c < sizeof($files); $c++)
{
$test[$c] = str_replace( $test2, "", $test[$c]);
}
$file = $test;//* Mostra gli ultimi 5 elementi *//
//* It shows last 5 elements *//$tot = 5;
for($i = 0; $i < $tot; $i++ )
{
if(file_exists($path.DS.$folder.DS."thumbnail".DS.$file[$i].".jpg")){
$img = "$url/{$thumbfolder}thumbnail/$file[$i].jpg";
}elseif(file_exists($path.DS.$folder.DS."thumbnail".DS.$file[$i].".gif")){
$img = "$url/{$thumbfolder}thumbnail/$file[$i].gif";
} else $img = "";
?>
<track>
<title><?php echo $file[$i]; ?></title>
<location><?php echo "$url/$folder/$file[$i]";?></location>
<image><?php echo $img; ?></image>
</track>
<?php} //* thx to www.brompled.com to help for improvements*//
?>
</trackList>
</playlist>mabao Friendmabao
- Join date:
- May 2008
- Posts:
- 13
- Downloads:
- 0
- Uploads:
- 0
- Thanks:
- 4
- Thanked:
- 1 times in 1 posts
July 27, 2008 at 4:22 pm #262569All Video Thumbnail/Playlist doesnβt work in Teline II Quickstart (1.0.15)
Would you advise me re. above problem? The factory default flv file is in the storiesvideos folder, while the thumbnail.flv.jpg image is in videosthumbnail, everything is left as it was set factory default. No thumbnail and no knowing how to give a second video when I wouldnβt like to have a second player, but a playlist instead. The dedicated playlist.php (scripted by Joomlart) is also next to the video file.
Iβve red every tutorial and post, but no definite answer, just the knowing that many other user experienced the same.
Thanks forward,
AttilaPS
No foreign modules, no modification, Joomla Quisckstart install provided by Joomlart packed with ver 1.0.15 for Teline II.February 21, 2009 at 1:41 pm #292754Hi, I needed custom description name into filename video… so I found this quick & dirty solution (avoiding the 2nd vector dimension).
Working on Giorgia modification, I added just another vector, be sure to insert manually proper descriptions (the array dimension is $tot value).<?php
define('DS', DIRECTORY_SEPARATOR);
$folder = (isset($_REQUEST['folder'])) ? $_REQUEST['folder'] : "";
$thumbfolder = ($folder) ? $folder."/" : "";//* Con questa funzione i files si ordinano in base alla loro data di creazione/ultima modifica *//
//* With this function files are ordinated by their creation date/last modification *//function ordina( $file1, $file2 )
{
$tempo1 = filectime($file1);
$tempo2 = filectime($file2);
return ($tempo1 < $tempo2) ? 1 : -1;
}function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS', 'php'), $include = array('flv','mp4','swf','3gp','mp3','rbs'))
{
// Initialize variables
$arr = array ();// Is the path a folder?
if (!is_dir($path)) {
?>
<script language="javascript" type="text/javascript">alert('Path is not a folder <?php echo $path; ?>'); </script>
<?php
return false;
}// read the source directory
$handle = opendir($path);
while (($file = readdir($handle)) !== false)
{
$dir = $path.DS.$file;
$isDir = is_dir($dir);
if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) {
if ($isDir) {
if ($recurse) {
if (is_integer($recurse)) {
$recurse--;
}
$arr2 = files($dir, $filter, $recurse, $fullpath);
$arr = array_merge($arr, $arr2);
}
} else {if (preg_match("/$filter/", $file)) {
$path_parts = pathinfo($path.DS.$file);
if(in_array($path_parts['extension'], $include)){
if ($fullpath) {
$arr[] = $path.DS.$file;
} else {
$arr[] = $file;
}
}
}
}
}
}
//closedir($handle);//asort($arr);
return $arr;
}
$path = dirname(__FILE__);
$files = files($path.DS.$folder);$url = dirname($_SERVER['REQUEST_URI']);
?><playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>CG Playlist</title>
<trackList>
<?php$test = array();
//* Con questo vettore Γ¨ possibile specificare una descrizione del video diversa dal nome esatto del video stesso*//
//* Specify your description to each videos (originally just the exact filename is shown) *//$testA = array();
$testA[0] = "First video description here";
$testA[1] = "Second video description here";
$testA[2] = "Third video description here";
$testA[3] = "Last video description here";
$test2 = $path.DS.$folder;
for( $c = 0; $c < sizeof($files); $c++)
{
$test[] = $test2 . $files[$c];
}
usort($test,'ordina');for( $c = 0; $c < sizeof($files); $c++)
{
$test[$c] = str_replace( $test2, "", $test[$c]);
}
$file = $test;//* Mostra gli ultimi 5 elementi *//
//* It shows last 5 elements *//$tot = 4;
for($i = 0; $i < $tot; $i++ )
{
if(file_exists($path.DS.$folder.DS."thumbnail".DS.$file[$i].".jpg")){
$img = "$url/{$thumbfolder}thumbnail/$file[$i].jpg";
}elseif(file_exists($path.DS.$folder.DS."thumbnail".DS.$file[$i].".gif")){
$img = "$url/{$thumbfolder}thumbnail/$file[$i].gif";
} else $img = "";
?>
<track>
<title><?php echo $testA[$i]; ?></title>
<location><?php echo "$url/$folder/$file[$i]";?></location>
<image><?php echo $img; ?></image>
</track>
<?php} //* thx to www.brompled.com to help for improvements*//
?>
</trackList>
</playlist>Thanks to Giorgia for original modification.
Enjoy. -
AuthorPosts
This topic contains 10 replies, has 5 voices, and was last updated by armybot 15 years, 9 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum