+ Post New Thread
Results 1 to 3 of 3

Thread: PHP Script to play media files from a web directory

  1. #1
    Administrator
    Join Date
    Mar 2013
    Posts
    2,803

    PHP Script to play media files from a web directory

    Hi, im looking for the script that will enable me to play media files like avi mp4 mp3 in certain web directory and its subdirectories.
    Do you know any such?




    I found JW Player which supports mp4, m4v, f4v, mov, flv, webm, aac, m4a, f4a, mp3, ogg, oga


    This is script to create playlist out of a local web folder and load JW player to play it.


    Example:
    Name:  1VJfm.jpg
Views: 1228
Size:  31.3 KB


    Code:
    cd /your/www/directory
    mkdir media
    cd media
    vi index.php

    paste:
    Code:
    <?php
    $path = "./files/";
    $path2="http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["PHP_SELF"])."/files/"; 
    //echo $path2;
    $folder = opendir($path);
    $start="<asx version='3.0'>\n<title>Example ASX playlist</title>";
    $Fnm = "./playlist.xml";
    $inF = fopen($Fnm,"w");
    fwrite($inF,$start."\n");
    while( $file = readdir($folder) ) {
         if (($file != '.')&&($file != '..')&&($file != 'index.htm')){
         $result="<entry>\n<title>$file</title>\n<ref href='$path2$file'/>\n<param name='image' value='preview.jpg'/>\n</entry>\n";
             fwrite($inF,$result);
         }
    }
    fwrite($inF,"</asx>");
    closedir($folder);
    fclose($inF);
    ?>
    <html>
    <head>
    <title>player</title>
    </head>
    <body>
    <center>
    <br/><br/>
    <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='470' height='470' id='single1' name='single1'>
    <param name='movie' value='player.swf'>
    <param name='allowfullscreen' value='true'>
    <param name='allowscriptaccess' value='always'>
    <param name='wmode' value='transparent'>
    <param name='flashvars' value='playlistfile=playlist.xml&image=preview.jpg&playlist=bottom'>
    <embed
    type='application/x-shockwave-flash'
    id='single2'
    name='single2'
    src='player.swf'
    width='470'
    height='470'
    bgcolor='undefined'
    allowscriptaccess='always'
    allowfullscreen='true'
    wmode='transparent'
    flashvars='playlistfile=playlist.xml&image=preview.jpg&playlist=bottom'
    />
    </object>
    <br/><br/>
    Download videos: (right clic + save as)<br/><br/>
    <?php
    $dir = opendir("./files");
    while($file = readdir($dir)) {
    if(($file == "index.htm") || ($file == ".") || ($file == "..")){} else {
    echo 
    
    
    "<a title='".$file."' href='".$path.$file."'>".$file."</a><br/>";
    }
    }
    
    
    closedir($dir);
    ?> 
    <br/>
    </center>
    </body>
    </html>

    Code:
    touch playlist.xml;chmod 777 playlist.xml

    download "JW Player" package from internet, example: http://www.porse.cz/JW_Player/download.html
    extract it and it should contain player.swf and preview.jpg


    copy these into your /your/www/directory/media


    so you have index.php, playlist.xml, player.swf and preview.jpg in your media www folder, now create folder for your audio and video:


    Code:
    mkdir files
    (should be named as files, else you need to edit index.php)


    if you want this web audio/video player all in one, you can download this whole file and extract it into your wanted www directory:
    player.zip

  2. #2
    Junior Member jonray76's Avatar
    Join Date
    Feb 2015
    Posts
    1


    Is this useful / helpfull? Yes | No
    any possible way to get someone to make a quick doc on how to do this for a website I run for our church? We have the pastor uploading his files to a folder on the server and I would like to have a page that viewers can go to and hear the songs with player and not have to edit the HTML to add each file each time. I can explain further if someone can help me. THANKS IN ADVANCE!

  3. #3
    Administrator
    Join Date
    Mar 2013
    Posts
    2,803


    Is this useful / helpfull? Yes | No
    jonray76, try to download file i attached to mi first post (player.zip) and extract it on your webserver. After extracting, you should have a folder called "player" and inside is this:
    Name:  web-media-player.gif
Views: 985
Size:  1.3 KB
    add your media to the folder "files" and open index.php in web browser. If that dont work, i will try to fix/find solution.

+ Post New Thread

Similar Threads

  1. How does social media play into an SEO strategy?
    By gitanistone in forum SEO - Search Engine Optimisation
    Replies: 0
    Last Post: 09-05-2019, 08:22 AM
  2. How does social media play into an SEO strategy?
    By dinialfort in forum SEO - Search Engine Optimisation
    Replies: 0
    Last Post: 03-24-2018, 11:36 AM
  3. How does social media play into an SEO strategy?
    By Sonamkumari in forum SEO - Search Engine Optimisation
    Replies: 1
    Last Post: 09-05-2017, 10:10 AM
  4. What role does social media play in an SEO strategy?
    By goyalenergy in forum SEO - Search Engine Optimisation
    Replies: 5
    Last Post: 12-01-2014, 06:40 AM
  5. Replies: 0
    Last Post: 04-17-2014, 08:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam