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

Auto scan, auto play playlist


yes im very new to embedding and web development..i found this code on how to scan a folder and create playlist thru xml. so thats done...now my problem is..is it possible for it to play automatically and not echo it as links? what i want to do is play all the content of a folder into jwplayer..thanks in advance...

the code that i got from here (scans and echoes links for playlist)

bc.. <?php
$path = "./12345/";
$path2="http://".$_SERVER['localhost'].dirname($_SERVER["PHP_SELF"])."/12345/";
$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("./12345");
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>

16 Community Answers

Ethan Feldman

JW Player Support Agent  
0 rated :

Change:

&playlist=bottom

To:

&playlist=bottom&repeat=always&autostart=true

JW Player

User  
0 rated :

i tried what you suggested and it didnt seem to do anything different.

on another note...thanks for the reply ethan. Thats why i chose to ask here, i saw that you and others are very active in trying to help.

JW Player

User  
0 rated :

according to what ive read from other threads...i need to create an RSS feed which i dont know if ive done correctly...ive just merged codes from what ive found here and tried to logically debug them as one...

this is the code for rss generation (which doesnt create the right playlist)
bc.. <?php
$path = "./12345/";
$xmlfile = "$path/playlist.rss";
$path2="http://".$_SERVER['localhost'].dirname($_SERVER["PHP_SELF"])."$path";
$folder = scandir($path);
$files = array();
foreach($folder as $file) {
if (($file == '.' OR $file == '..' OR $file == 'index.htm'){}else{
$files[$file] = filemtime($path.'/'.$file);

}
}
$output="<rss version='2.0' xmlns:jwplayer='http://rss.jwpcdn.com/'><channel>";
foreach($files as $file => $date){
$output .= "" . PHP_EOL . "<item>" . PHP_EOL . "<title>$file</title>" . PHP_EOL . "<description>$file</description>" . PHP_EOL . "<jwplayer:image>./preview.jpg</jwplayer:image>" . PHP_EOL . "<jwplayer:source file='$path/$file' />" . PHP_EOL . "</item>" . PHP_EOL . "" . PHP_EOL;
}
$output .= "</channel></rss>";
file_put_contents($xmlfile,$output);
?>
<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$repeat=always&autostart=true'>
<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 click + save as)<br/><br/>-->
<?php
$dir = opendir("./12345");
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>



the path 12345 is a folder in my root folder which contains the images and movies to play...



this is the code that supposedly should display the content

bc.. <html>
<head>

<title>SWFObject dynamic embed - step 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="jwplayer.html5.js"></script>
<script type="text/javascript" src="jwplayer.js"></script>

<style>
p.pos_fixed
{
position:fixed;
top:250px;
right:1145px;
}
p.pos_fixed2
{
position:fixed;
top:300px;
right:1328px;
}
p.pos_fixed3
{
position:fixed;
top:400px;
right:1307px;
}
</style>
<link rel="shortcut icon" href="site_images/logo.ico" type="image/x-icon">
<link rel="icon" href="site_images/logo.ico" type="image/x-icon">
<link href="mystyle2.css" rel="stylesheet" type="text/css">
<title>izGate</title>
</head>
<body>

<div style="position:absolute;top:250px;left:350px;"><div id="myPlayer">Loading the player...</div>

<script type="text/javascript">
jwplayer("myPlayer").setup
({
//flashplayer: "/jwplayer/jwplayer.flash.swf",
controlbar: "none",
dock: "false",
autostart: "true",
repeat: "always",
height: "350",
width: "700",
getFullscreen: "false",

playlist: 'playlistfile=playlist.rss&image=preview.jpg&playlist=bottom',
//[{
//file: "12.php"
//file: "/12345/1.mp4"
//file: "playlistfile=playlist.xml"
//}]
});
</script>


<form action="" method="POST" enctype="multipart/form-data">
<p class="pos_fixed"><input type="file" name="image">
<p>
<p class="pos_fixed2"><input type="submit" name="upload" value="Save">
<p class="pos_fixed3"><input type="submit" name="playlist" value="Manage">
</form>
</body>
</html>

<?php
session_start();
$name = $_SESSION["name"];
$pass = $_SESSION["pass"];

$hostname = 'localhost';
$username = 'root';
$password = 'strongpassword';
$dbname = 'user';
mysql_connect($hostname, $username, $password) or DIE('Unable to connect to NAS, check if SQL server is enabled');
mysql_select_db($dbname) or DIE('Database is not available!');

$query0=mysql_query("SELECT * FROM tbl_user_accounts WHERE (user_name = '" . mysql_real_escape_string($name) . "') and (user_pass = '" . mysql_real_escape_string($pass) . "')");
$row0=mysql_fetch_array($query0);
$id = $row0['user_id'];
$serial = $row0['user_serial'];

if(isset($_POST['upload']))
{
$image_name = $_FILES['image']['name'];
$image_type = $_FILES['image']['type'];
$image_size = $_FILES['image']['size'];
$image_tmp_name = $_FILES['image']['tmp_name'];
//$image_path = "upload_file/";
$image_path = $serial;

if($image_name=='')
{
echo"<script>alert('Please select an image')</script>";
exit();
}
else
move_uploaded_file($image_tmp_name,$image_path."/$image_name");
$query=mysql_query("INSERT INTO tbl_photos (photo_title, photo_link, photo_image_link, photo_user_id, photo_serial) VALUES ('$image_name ', '" . $image_path . $image_name ."' , '" . $image_path . "' , '" . mysql_real_escape_string($id) . "', '" . mysql_real_escape_string($serial) . "')");
echo "</br>";
echo "upload successful";
echo "</br>";
echo "<img src='upload_file/$image_name', width='350', height='350'>";
//header("Location: 3.php");
}

if(isset($_POST['playlist']))
{

}
?>



im really lost on how to debug this...

note: what i intend to accomplish is scan a folder exclusive to the user who logged in the website(this folder is created along with the account details. and will hold uploaded images/videos from that user)...then when the user visits the URL to embed this codes, he would just simply tag his folder name and should retrieve and play all the media contents of his folder....

if anyone could help me figure this out it would really be much appreciated.

Ethan Feldman

JW Player Support Agent  
0 rated :

Hm, do you have a link?

JW Player

User  
0 rated :

im sorry but i dont have..im hosting this locally doing tests using wamp server. but is it possible to achieve what i want to happen?

using the code from the auto playlist xml i can generate a page where all the contents are shown in a list and all are linked. each are needed to be clicked for it to play on another page...maybe theres a way to auto play this list and not load them as lists?

Ethan Feldman

JW Player Support Agent  
0 rated :

Yes, I believe it is possible, I would just need to see the example so I can debug it.

JW Player

User  
0 rated :

well..i can give you the code that works but needs to be tweaked.

here is the code that scans the folder... (path 12345 is in my root dir.)

bc.. <?php
$path = "./12345/";
$path2="http://".$_SERVER['localhost'].dirname($_SERVER["PHP_SELF"])."/12345/";
$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("./12345");
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>



now what i hope to do is immediately play the contents of the folder upon the load of this page.

Ethan Feldman

JW Player Support Agent  
0 rated :

Sorry, I can’t much sense of this without seeing this in action.

JW Player

User  
0 rated :

well in any case. i figured out a way to work around this problem...now a new question comes to mind...

can you lead me to any forums or site that would introduce me into content managing/editing on my website? id like the users on my website to be able to upload images/videos and be able to edit it in someway before they publish it. where do i start with this? tnx in advance.

Ethan Feldman

JW Player Support Agent  
0 rated :

You might be able to use a script like Clip Bucket for something like this.

JW Player

User  
0 rated :

ok thanks for the help ethan

Ethan Feldman

JW Player Support Agent  
0 rated :

np

JW Player

User  
0 rated :

hello again Ethan. I just got clipbucket to work and i havent really explored it much but definitely will..i just want to ask as a heads up so i know what areas to explore...can clipbucket be integrated to my website as a script/plugin? and not as a whole clipbucket MMS? what i mean is that i want the ability and features of clipbucket to manage multimedia and integrate it to my site and not put clipbucket as is to it?

Ethan Feldman

JW Player Support Agent  
0 rated :

I believe it has to be used as a full CMS.

JW Player

User  
0 rated :

ok ethan, again thanks for your quick reply even to these trivial questions.

Ethan Feldman

JW Player Support Agent  
0 rated :

Np

This question has received the maximum number of answers.