Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • gaygiorgia Friend
    #130061

    I 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_namevideo3

    if i add a new video and name it 4_namevideo4, playlist becomes:
    1_namevideo1
    2_namevideo2
    3_namevideo3
    4_namevideo4

    Now, instead, with rsort($files); playlist is:
    4_namevideo4
    3_namevideo3
    2_namevideo2
    1_namevideo1

    Solving 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
    ================================

    😎

    hdfilm Friend
    #255900

    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 πŸ™‚

    gaygiorgia Friend
    #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. πŸ™‚

    hdfilm Friend
    #256066

    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 πŸ™‚

    gaygiorgia Friend
    #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 Friend
    #256311

    HI gaygiorgia
    Thank for sharing
    Can I mark this topic is solved ?

    gaygiorgia Friend
    #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 Friend
    #256618

    Ok, 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 Friend
    #262569

    All 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,
    Attila

    PS
    No foreign modules, no modification, Joomla Quisckstart install provided by Joomlart packed with ver 1.0.15 for Teline II.

    armybot Friend
    #292754

    Hi, 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.

Viewing 10 posts - 1 through 10 (of 10 total)

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