Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

automatic playlist script


it's a script which builds a playlist.xml and loads jw player, with automatic folder scan, and files download.
create a "player" folder (example) on root, upload index.php (this script), player.swf, preview.jpg, create a folder "files" in "player", upload your files.

demo here: http://maz38.free.fr/test/

bc.. <?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("./fichiers");
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>



to protect your "files" folder, upload an index.htm in "files":

bc.. <html>
<head>
<META http-equiv="refresh" content="0; URL=..">
</head>
<body>
</body>

29 Community Answers

JW Player

User  
0 rated :

Hi friends...

this script is AWESOME...

GREAT WORK...

NOTE: this script just work with JW Player 5.2, with before versions not work...

JW Player

User  
-2 rated :

I make some tests and I say this GREAT SCRIPT works with JW PLAYER 5.1.897 to UP versions...

THANKS FRIENDS...

JW Player

User  
0 rated :

This seems like an incredible script, but I can't get it to work.
Once I changed "fichiers" to "files" I got the list of files to display, but still no player.

Can you guys take a look at my index.php and help me get this working PLEASE !

http://mercuryexposure.info/player/

Thank you very much for any help you can offer

JW Player

User  
0 rated :

it seems as though when the script creates the "playlist.xml" it makes 3 slashes in the web address when referencing the files

Ethan Feldman

JW Player Support Agent  
0 rated :

Your embed code has a ton of broken symbols in it.

Example embed code is here for your reference – http://www.longtailvideo.com/support/jw-player-setup-wizard

JW Player

User  
0 rated :

Do you mean the index.php or the playlist.xml ?
I followed the directions above, where index.php automatically generates the playlist.xml
which is incorrect ?

Ethan Feldman

JW Player Support Agent  
-1 rated :

I mean your embed code in the php file

JW Player

User  
0 rated :

okay I copied the embed code I made from that link and put it into the index.php file, but still no luck. When I examine the playlist.xml that the index.php made the weblinks contain 3 forward slashes ( http:///) but even when I fix this it doesn't play. Please Help !

bc.. <?php
$path = "./files/";
$path2="http://".$_SERVER['mercury exposure'].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='single2' name='single2'>
<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=http://www.mercuryexposure.info/player/playlist.xml&playlist=bottom'>
<embed
id='single2'
name='single2'
src='player.swf'
width='470'
height='470'
bgcolor='#000000'
allowscriptaccess='always'
allowfullscreen='true'
flashvars='playlistfile=http://www.mercuryexposure.info/player/playlist.xml&playlist=bottom'
/>
</object>
<br/><br/>
TO DOWNLOAD VIDEOS: (right click + 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>

Ethan Feldman

JW Player Support Agent  
0 rated :

Remove all the
parts, that breaks it.

JW Player

User  
0 rated :

How can you order the playlist.

I have video which are 001, 002, 003 however the xml is not in any order.

Please can you let me know.

Thanks

Ethan Feldman

JW Player Support Agent  
0 rated :

Link ?

JW Player

User  
0 rated :

Sent you a PM

Ethan Feldman

JW Player Support Agent  
0 rated :

Ok.

JW Player

User  
0 rated :

Ok, if anyone could help please.

I need to arrange the uploads of the videos by date.

bc.. $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);
?>



Can any one help please.

Ethan Feldman

JW Player Support Agent  
0 rated :

PHP has a date function, I would look into that.

JW Player

User  
0 rated :

Heloo, i need advice on how to automatically create playlists from the database. Playlist would be formed by id category. Previous versions of player transfer function of such parameters, but now I do not know how to pass parameter according to the new syntax.
Old syntax
bc.. <script type='text/javascript'>
var so = new SWFObject('../mp3/player5.swf','ply','880','260','9','#000000');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('playlistfile','../mp3/playlist2.php?id_kat=<?php echo (!empty($_GET['kat'])? $_GET['kat']:"1"); ?>/');
so.addVariable('playlistsize','400');
so.addVariable('playlist','right');
so.write('mediaspace');
</script>


New syntax ??playlistfile??
bc.. <script type="text/javascript">
jwplayer("mediaplayer").setup({
flashplayer: "../mp3/player-59.swf",
file: "../mp3/playlist4.php?id_kat=5", // ??
'width': '880',
'height': '260',
'playlist.position': 'right',
'playlist.size': '320'
});
</script>



Thanks

Ethan Feldman

JW Player Support Agent  
0 rated :

We don’t have any scripts that show people how to do this.

JW Player

User  
0 rated :

Is there any reason the the above scrip would not work on the ipad which HTML ?

Ethan Feldman

JW Player Support Agent  
0 rated :

As long as you are using files that the iPad accepts, and using the JW Embedder, it should work…

JW Player

User  
0 rated :

This version is not working on iphone
how it can be made to work on iphone ?

Ethan Feldman

JW Player Support Agent  
0 rated :

@Kashif – Do you have a link?

JW Player

User  
0 rated :

Ethan I changed the playlist asx to mrss and now its working for iphone

but playlist scroll is not showing in iphone and its only showing 5 videos on iphone but I have added 7 videos which is visible on pc
see the below link on iphone if you can
http:// marsgibson . info/odesk/
(remove spaces)

I have used the following jwembed code
bc.. <div id="html5playlist"></div>
<script type="text/javascript">

jwplayer("html5playlist").setup({
modes: [
{ type: "html5" },
{ type: "flash", src: "player.swf" }
],
playlist: [

<?php
include("playlist.php");
?>
],

width: 700,
"playlist.position": "right",
"playlist.size": 240,

skin: "glow.zip"
});
</script>

Ethan Feldman

JW Player Support Agent  
0 rated :

On iOS, you need to use two fingers, and it will scroll.

JW Player

User  
0 rated :

Is there a way to get the video thumbnail and video description automatically just like getting the playlist automatically ?

Example
description folder contain *.txt file
image folder contain *.jpg file

the video file description file and image file will be named same so it will automatically create it

I tried to use the same above method by I failed at using while command

Ethan Feldman

JW Player Support Agent  
0 rated :

You need to have the images on your server. We do not have a playlist generation script sample.

JW Player

User  
0 rated :

I think have some troubles with relative and absolute path.

I try with default directory example (created player etc.).

Then changed with mine and modify the script in this ways without any result.
bc.. <?php
$path ="http://www.my_site.com/my_path_/videos/";
$path2="http://www.my_site.com/my_path_/videos/";
$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>Autoplaylist</title>
<script type='text/javascript' src='/my_path/jwplayer.js'></script>
</head>
<body>
<div id='autoplaylist'><a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="scarica Adobe Flash Player">
</a><br>Per vedere questo contributo scaricate gratuitamente Flash player cliccando sull'immagine in alto</div>

<script type="text/javascript">
jwplayer('autoplaylist').setup({
'flashplayer': '/my_path/player.swf',
'id': 'playerID',
'width': '650',
'height': '620',
'playlistfile': 'http://www.my_site.com/my_path_/videos/',
'playlist.position': 'bottom',
'playlist.size': '120',
'controlbar': 'over',
'repeat': 'list',
'backcolor': '000000',
'frontcolor': 'ffffff',
'lightcolor': 'ffcc00',
'autostart': 'true',
});
</script>
Download videos: (right clic + save as)<br/><br/>
<?php
$dir = opendir("./images/stories/videos");
while($file = readdir($dir)) {
if(($file == "index.htm") || ($file == ".") || ($file == "..")){} else {

echo
"<a title='".$file."' href='".$path.$file."'>".$file."</a><br/>";

}
}
closedir($dir);
?>
<br/>
</body>
</html>


to my seems that php don't compile anything and stop after the $start command.

here a link http://www.fitet.tv/images/stories/videos/autoplaylist_ago_2012.pxp

Ethan Feldman

JW Player Support Agent  
0 rated :

According to Firebug, this file is missing – http://www.fitet.tv/images/stories/videos/playlist.xml

JW Player

User  
0 rated :

well i made a php script that does sort of what he wants maybe he should look


http://www.longtailvideo.com/support/forums/jw-player/using-playlists/30326/create-a-playlist

Ethan Feldman

JW Player Support Agent  
0 rated :

Thanks :)

This question has received the maximum number of answers.