Fli
04-17-2014, 04:27 PM
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:
100
cd /your/www/directory
mkdir media
cd media
vi index.php
paste:
<?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>
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:
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:
101
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:
100
cd /your/www/directory
mkdir media
cd media
vi index.php
paste:
<?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>
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:
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:
101