Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Image Folder instead of Playlists

63 replies [Last post]

I'm not sure if this is possible or not, but I thought I'd ask...

Is it possible to not have a playlist, but instead have the images and captions (html files with the same name as the photo) be pulled from a folder? It would make updating images a breeze...

Having a simple cgi-script, php-script (or whatever your webserver allows to use) that creates a playlist from the images using the captions would allow to do that without the need to change the player.

Do you know where I could find a tutorial on how to do that?
I don't speak cgi or PHP... :(

Creating a playlist on the fly is definitely the way to go. Hi - this is my first post but I have been working on the auto-playlist thing lately.

Jeroen has a simple script in the extras folder that can do this. <a href="readdir_playlist.zip"> Set the filter to ".jpg" instead of ".mp3" and it will make you a list of all such items in your folder. I don't know anything about the captions stuff yet. If they all have the same suffix ie:txt you could modify Jeroens script to look for those as well and massage them into the correct xml format.

thanks - this place is a great resource

@Carl,

Look around on the forums a bit before yu put much effort into a playlist generator. Various users have posted playlist generators that will do almost anything.

For captions, there are many Open Source and commercial generators available, so I've never seen the need to make anything for that.

If users would explain what result they want to have, it would be much easier to help them. No one's going to put a lot of effort into some vague, undefined, I'd like to have this...

Carl, Thanks for the advice.

Will, do you have any links you could share? I don't even know where to begin to look for something like that...

@Benjamin,

What I need first is a detailed description of what you want to do.

As much detail as you can think of. Once we know how you want it to appear and what media you have available, we can help you implement a solution.

So, write down as much as you can about what you have, what you want to do, how you want the result to appear, etc. Then we'll propose solutions.

I'm working on a webpage to display images from a folder on my presentation disc by using the jw rotator. Could anyone give me the embedded code for my html page? Thanks.

@Thomas,

If you look at this post [url=http://www.jeroenwijering.com/?thread=6080#msg27251]Standalone CD Slideshow from Image Rotator[/url], you will find the basic code for using the Image Rotator to display images from a CD.

@Will

I'm building my online portfolio.

I currently have all my images divided into folders.
My images are named according to title, spaces and all (eg. "A Forest Picture.png")
I also have descriptions of each photo (saved as HTML files) in the folder as well, titled the same as the image file (eg. "A Forest Picture.html")

I would like the image rotator to automatically pull from whatever photos and images happen to be in the folder to make the gallery.

Also, I had another question; has anyone built any MySQL plugins for this, so users can comment on photos?

Thanks!

@Benjamin,

OK, now we're starting to get a picture of what you want to do.

Here's a suggested system. We may need to make some changes depending on how you want to set up your main page, but at least this gives us a framework to start building upon.

1) The mainpage would have some sort of a selection display. Maybe thumbnails linked to a particular folder.

2) When a user clicks on a selection, an image rotator will be loaded with a playlist that is generated on-the-fly from the images in the selected folder. This image rotator can be in a popup (maybe not so good, because lost of users may be using poopup blockers) or a new page.

3) It's not clear what you want to do with the HTML.
a) If I was doing a gallery where I wanted some text displayed that was a description of the image, I might place some sort of text (captions) display either over the lower portion of the picture or in a separate player immediately below the image rotator.
b) You could display the text describing the image only when the user clicked on the image.

You will have to further define 3).

I haven't seen a MySQL based comment system, but Google or another user might have seen one.

@Will

1) That's fine.

2) I think it would be best to load it directly on the page. Popups can be too easily blocked. Where would I find code for the playlist generator?

3) I think below the picture would work great. Here's am example gallery that I currently built, built using PHP. http://www.zerflin.com/artwork/Vector/
Each picture's description appears below the image.

@Benjamin,

Here's the basic playlist code. You will need to adjust the default $directory, default $imageuri, and $infourl variables. If you don't want any line of the tracklist comment it out like I have commented out the music line, or uncomment it as desired.

playlist.php

<?php

// This is a sample file that reads through a directory, filters the mp3/jpg/flv
// files and builds a playlist from it. After looking through this file, you'll
// probably 'get the idea' and'll be able to setup your own directory.

// search for jpg files. set this to '.flv' or '.mp3' for the other scripts

$filter  = ".jpg";
$pattern = '/\\' . $filter . '/';

// path to the directory you want to scan  ** no trailing slash **
$directory = (isset($_GET["dir"])) ? strval($_GET["dir"]) : "C:/images/gallery_1";

// image domain  ** no trailing slash **
$imagedomain = "http://my.domain.com";
$imageurl = $imagedomain . "/" . (isset($_GET["uri"])) ? strval($_GET["uri"]) : "images/gallery_1";

// info URL
$infourl = "http://my.domain.com/";

// read through the directory and filter files to an array
@$d = dir($directory);
if (
$d)
{
  while(
$entry=$d->read())
  {
   
$ps = strpos(strtolower($entry), $filter);
    if (!(
$ps === false))
    {
     
$items[] = $entry;
    }
  }
 
$d->close();
 
sort($items);
}

// the playlist is built in an XSPF format
// first, we'll add an xml header and the opening tags...
header("content-type:text/xml;charset=utf-8");

echo

"<?xml version='1.0' encoding='UTF-8'?>
\n";
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo "  <title>Sample PHP Generated Playlist</title>\n";
echo "  <info>http://www.jeroenwijering.com/</info>\n";
echo "  <trackList>\n";

// ...then we loop through the array...
for($i=0; $i<sizeof($items); $i++)
{
  $title = preg_replace($pattern, '', $items[i]);

  echo "    <track>\n";
  echo "      <title>" . $title . "</title>\n";
  echo "      <location>" . $imageurl . '/' . $items[$i] . "</location>\n";
//echo "      <link rel=\"audio\">http://my.domain.com/Music/songbig.mp3</link>\n";
  echo "      <info>" . $infourl . "</info>\n";
  echo "    </track>\n";
}

// ...and last we add the closing tags
echo " </trackList>\n";
echo "</playlist>\n";

/*
* That's it! You can feed this playlist to the SWF by setting this as it's 'file'
* parameter in your HTML page.
*/

?>

For the main page, you will need to place the thumbnails and start a default image rotator. Then use JavaScript to load a new playlist when the user clicks on a thumbnail.

Here is a basic HTML line for a thumbnail. If you need help composing the page and player, it will take me a while to put it all together.

  <a href="javascript:loadFile({file:'playlist.php?dir=C:/images/gallery_1&uri=images/gallery_1'})"><img src="thumb_1.jpg" alt="Click to view this gallery" width="80" height="80" border="0" /></a>

This revised generator has some very nice features ie: full pathnames and GET interface code. The playlist_generators based on the Lewis Smith code were way too complicated unless you really neeeded the id3 info.

I think it is worth noting by example where the php_generator (playlist.php) file actually goes in the embed code. As Jeroen explains at the bottom "You can feed this playlist to the SWF by setting this as it's 'file' * parameter in your HTML page."

var s1 = new SWFObject("imagerotator.swf","rotator","240","360","7");
s1.addVariable('width', '240');
s1.addVariable('height', '360');
s1.addVariable("file","playlist.php"); <======

Could you talk more about getting the .html caption files written out with the images? and/or reference some discussion on the caption topic. Thanks.

A 2nd Note Tonight - I since discovered (sadly) that the caption option doesn't work with the imagerotator. This seems like a feature everyone would want with a slideshow. I found your thread with Mossimo on this topic that suggested using two players. This certainly has useful possibilities. (Everyone-see the website!)

I guess I would encourage caption support in the next imagerotator release. I have noted that you can write an info comment into a <div> using javascript. This is a good option for a little extra work.

One last idea - Could we just get captions from plain text files without the fancy formatting. Thanks again.

@Carl,

Some of the other playlist generators have 5 sorting methods including artist, title, or date based on the typical MP3 naming format with date added. Like this: "Quentin Tarentino - Kill bill - 01-05-2005.flv"

Captions are necessarily complex because they are meant to display the dialog for a movie in another language or to provide written dialog for handicapped access.

If I just wanted text on an image in the Image Rotator, I would use the method I whipped up a while ago for a newsfeed. It uses PHP's imagecreate() functions to overlay text (can be any TTF or other font) on an image. I experimented with a lightened rectangle in the original image as well as adding a rectangle with any background color to the bottom of the image as a background for the text. The possibilities are limitless. And the text comes from a plain text file. In the case of the newsfeeds, the text file was generated from RSS newsfeeds, but it could come from anywhere.

All the posts seem to have disappeared - that's one big problem with these forums, posts seem to mysteriously disappear. Anyway, I still have the code. You can see a demo here: [url=http://willswonders.myip.org:8085/php/newsfeed_test.html]Newsfeed Demo[/url]. The text isn't live because I don't have the newsfeed parser running, but you can see how it works.

The text comes from a plain text file, as many lines as you want per image. Any font or formatting that you want.

If you are interested, I can make the code available and help you implement the system.

It's really quite simple.
1) A page with one or more Image Rotators
2) A source of images
3) A playlist generator
4) A script to generate the images with overlaid text
5) A newsfeed parser to generate the text file
6) A script to stream the images that prevents storing the images in the browser's cache, so the browser has to get fresh images

This system was designed to display live news on top of live images. If you just want static text on static images, you could run the image generator once, then serve the images with text normally. You wouldn't need 5) and 6) above.

I've written dozens of specialized playlist generators, so it's getting to be relatively easy to pull up the one that is closest to what someone wants and modify as needed.

Using multiple players (I have pages with four reflecting, "Wet Floor" effect players), JavaScript, and server-side scripts enables you to do anything. The only thing I haven't figured out yet is timing song lyrics automatically. So far, that just takes a lot of time to do. But there are researchers working on automatic captioning for handicapped access and one day soon, we will have that also.

Hi,

First of all, thank you to all of the experts who have generously posted code and hints for all of us n00bs.

I was wondering if someone could help me, I have a media player set up with my playlist on the right of the player, but I was wondering if there is a simple way to move it to the left of the media player?

Thanks in advance,
Amy

@Amy - no, that would take majour changes in the player itself and recompiling...
you can use html/css/js though, please see the [url=http://home5.inet.tele.dk/nyboe/flash/mediaplayer/]demos[/url] for examples of placing playlists anywhere...

@Will

Thanks for taking the time to write back regarding the captions issue. I personally would be interested in learning more about using the imagecreate() function but I'm not sure it is mainstream conversation. Your explanation about the need for an extensive captioning tool makes sense for some applications. I still think that being able to use plain text as an optional caption format would be a welcome addition.

I think your larger following would really like an easy way to caption images.
Do you think that captions will be added to the next imagerotator?

* Here is a simpler idea. (If you could make sure Jeroen sees this I really think it has merit)
Make the "Annotate" command into an automatic caption command.
Add a flashvar such as:
s0.addVariable('Anno', 'annoID'); where annoID is the id of the destination div for the text
(basically you would simply build in the js info solution now being used)

Thanks - Carl

@Carl,

I'm not speaking for Jeroen, but I generally agree with his expressed philosophy, "I receive a lot of requests for creating customized versions of my players. In most cases however, a clever setting of the flashvars already fulfilled the requests, so please make sure you check these first!"

I would rather use the JavaScript API, multiple players, and server-side apps. to increase the functionality of the players. Look at what andersen has done in his demos without any modification of the players.

I'd like total control (pan, zoom, rate) of the Ken Burns effect, but I realize that this would be a lot of initial work and continued maintenance for a small user base (one!). So, if I just can't live without that, I will have to buy Flash8 and learn ActionScript.

If you try to make the players 'all things to all people', they will become a complicated, unmaintainable monster. Think Godzilla/Rodan/Mothra/Transformers all-in-one.

@Everyone & Jeroen, I would reiterate what Will has said above in regards to the flashvars. I've made a really slick looking player using only flashvars to create clever effects. I've also employed transparent png files as thumbnail graphics to create graphical playlist buttons - it really is a brilliant piece of software.

One other question though - bearing in mind I have my playlist on the right, is there any way I can make my control bar (progress slider etc) only run the width of the movie window and not the movie + playlist?

@Amy,

Ok, so let's see your handiwork. :)

A long, long time ago, in a place far, far away (well, not really, it was these forums) Jeroen said that it was not possible to limit the control bar size to only the display area using only the flashvars.

@Will,

Can't show you just yet, but will post a link when it's up somewhere. ;)

@Amy,

We shall await the grand presentation. :)

You know, it doesn't have to be perfect, look at all the junk I posted. Thanks to Jeroen, who added the edit, at least I can fix my infamous typOs.

@Will

I understand why you can't put in every feature request. I may not be a php expert but I have designed alot of production furniture, several websites and some software. Jeroen has gone to great lengths to make this product simple to use. Enabling the flashvar control concept is truly a stroke of brilliance.

It is still my opinion that a built-in annotation command should be a core option, particularily in an image rotator. Because you are obviously extremely knowledgeable in all of the processes you mentioned "JavaScript API, multiple players, and server-side apps" things may seem simple to you that appear foreboding to the larger user base.

I am now going to leave this topic alone. Please make sure that Jeroen reads this thread when he gets back so that I can get his feedback on the issue. To repeat - the concept is as follows:

Use the "Annotate" command as a built-in caption command.
Add a flashvar such as:
s0.addVariable('Anno', 'annoID'); where annoID is the id of the destination div for the text

Thanks, Carl

@Carl,

I'm a just a user like you.

If you want to bring something to Jeroen's attention, I'd suggest you put it in the "Wish List" thread.

My advocacy of the use of outside forces, ie., server-side scripts, multiple players, is because they are much more powerful than a single player running on a client's computer, therefore you can do much more, but that's up to each user to choose their preferred tools.

Yes, some of the applications are complicated, but andersen, other users, and myself have helped many users implement them and in the process extended their knowledge and capabilities tremendously and also provided a lot self-satisfaction to all of them.

@Benjamin,

Since you asked for links that use a bit about what you're looking for, I'm posting here links from my website were I use a lot Jeroen's player and also used some help from this forum.

This link gives you what Andersen was talking about, a javascript that calls not only xml playlist but php playlist also were you can add some captions (Description). The drop down list is were you choose your PHPs and they are made the same way as the XMLs but the extention changed to php. The mediaplayer gives you the advantage of using, FLVs, photos, SWF and MP3s.
[url=http://www.algeriacolor.com/en/music.htm]click here[/url] (don't choose the first six singers from the drop down list, it takes you to html page)

This other link gives probably what you are asking for. I'm using it but the only concern is that actually it doesn't work in IE but Firefox. I didn't have a chance to look around to fix it and actually I'm asking Will and Andersen for their expertise for a fix.
[url=http://www.algeriacolor.com/en/whosingswhat.htm]click here[/url]
hope these help.

@Zino,

The problems on your second page are caused by 'mpl' as the JavaScript id of the player being undefined.

However, I cannot find anything wrong with your code that would cause this.

I'm guessing it's because you are loading lots of files and trying to do an in-line load of the player's JavaScript code.

Also, I noticed that throughout your HTML, you are not always quoting HTML element ids. You are getting away with this because HTML is quite forgiving, unlike JavaScript, but sooner or later it will come back to bite you and it will be a very hard to find bug.

So, I'm suggesting that you wrap your player code in a function and move it to the <head> of the document, like this:

<script type="text/javascript">
function createPlayer()
{
  var so = new SWFObject('mediaplayer.swf', 'mpl' ,'720' ,'325' ,'2');
      so.addParam("allowfullscreen", "true");
      so.addVariable("file", "algeriacolor_.php");
      so.addVariable("enablejs", "true");
      so.addVariable("javascriptid", "mpl");
      so.addVariable("displayheight","325");
      so.addVariable("displaywidth","500");
      so.addVariable("logo","/Pictures/logi.png");
      so.addVariable('frontcolor','0x777777');
      so.addVariable('backcolor','0x000000');
      so.addVariable('lightcolor','0x999999');
      so.addVariable('thumbsinplaylist','true');
      so.addVariable('repeat','true');
      so.addVariable('autostart','false');
      so.addVariable('shuffle','flase');
      so.addVariable('useaudio','false');
      so.addVariable('usecaptions','true');
      so.write('player');
  var mmw = new SWFMacMouseWheel(so);
}
</script>

Then load it like this:

<body onload="javascript:createPlayer();"

If that doesn't fix the problem, we need to continue searching for the reason that the player's JavaScript id isn't getting propagated when the page loads.

@Zino
first of all you must make sure all files are where you tell the player to expect them, if just one file or picture is missing the player cant work...
for instance you tell the player:
http://www.algeriacolor.com/en/Pictures/logi.png
but in reality, i find the picture here:
http://www.algeriacolor.com/Pictures/logi.png

also your page is quite complicated with scripts and stylesheets...
better make a simple testpage, and make that work first - and then put in the other stuff - very often it is much faster to start over, than to try to debug!

I just noticed that your playlist is messed up.

algeriacolor_.php returns this:

<playlist
version="1"
xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<title>Chaabi, Andalou, Malouf</title>
<creator>Algeriacolor</creator>
<image>../photos/algeriacolorMenu__.png</image>
<location>algeriacolor/algeriacolor.mp3</location>
<info>Choose your favorite singer from the list above.</info>
</track>

</trackList>

1) It's missing the first line "<?xml version='1.0' encoding='UTF-8'?>" which is absolutely required.

2) It's missing the closing "</playlist>" tag.

Thanks Will, I'll give it a try when I get home and post the result here.

@ Andersen,
you are right but the website is in two languages and I'm using sometimes the same file on both and some other time one for each language. Also for the test page I did in the first place and was working and like you said, when you add more stuff to the page, things goes crazy :)

Ooops Will, that's a good point about the php file, I'll check all the mess and post the result.

@Zino,

i was so wrapped up in sleuthing through your code that I forgot to tell you that, "Your site looks VERY nice, VERY professional.. I'm looking forward to seeing it completely finished and working. And the music is very interesting also. :)

Thanks Will !! It is very encouraging.

Indeed the music is an old type brought back from a 1000 years ago it is the Andalousian music that went to Spain and becomes the Flamenco and kept in northern Africa as Andalou music which its derivatives are the pop music (Chaabi) and some others styles. Actually Andalou is a Classical music similar to the European one (Beethoven etc ...)

Will you eventually have some of the derivative music and an expanded explanation like you posted above? It's very interesting.

@Will

Yes I will give more explanation about the derivative that eventually you can find on the website (Chaabi, Malouf, Hawzi ...).
If you check "Beihdja Rahal" page you can listen to the exact andalousian type which is done by performing a Nouba that you may have seen this word and it means in certain way, all night singing and having fun. They are 24 Noubas (like 24 hours a day), 12 have been lost and some of them are incomplete, the other 12 are stand still as originally performed :)

Each Nouba last over an hour non stop and a huge memory of the long text/poem.

Now it is working correct.
[url=http://www.algeriacolor.com/en/whosingswhat.htm]click here[/url]

Will, I tried what you said above but it didn't want to work with IE so I rebuilt the page from my previous working test page by adding stuffs to it. I have no clue what was wrong but it is working now on both IE and Firefox.

For the php playlist and when adding
<?xml version='1.0' encoding='UTF-8'?>
the description (caption) doesn't work.

@Will

Either you or anderson wrote this just today. " a true text tag and callback would be the answer to a lot of problems" . I didn't know there was a wish forum but then I found the wishlist thread. I will look seriously at the <info> js solution. I did find anderson's demo.

Do you think that the captions might be available in the next rotator? The tt syntax actually looks pretty simple. It wouldn't take much of a .php program to open a .csv file and write it back out in tt. I *did* read all the discussion about existing conversion software. I have copied and edited Joeren's sample and this is the simplest way to get started. One caption option (I will put it in the wishlist) would be to be able to send captions to a designated <div>. If you can already do this, forgive me. Anyway - thanks - cheers

@Zino,

Post your code for your playlist generator "algeriacolor_php" and I'll help you get it straightened out. Then we can work on getting the JavaScript into a function in the <head>.

It's really the best way to do it and while your page may be working now, as your add to it, you may have problems with the player getting initialized, so we should straighten it out.

@Will,
here what I'm using as playlist generator and if you could I would like to change the location of the image to a different folder, let say photos folder.

''--
''--
''-- jeneratiff / musique
''-- Stylianos Dritsas (C) 2007
''-- http://jeneratiff.com
''--
''-- License: Creative Commons License
''-- http://creativecommons.org/licenses/by-nc-sa/3.0/
''--
''-- Scripting Object
set fs = createobject( "Scripting.FileSystemObject" )
''-- Playlist File Stream
set stream = fs.createtextfile( "playlist.php", true )
''-- Begin Playlist
call stream.writeline( "<playlist" )
call stream.writeline( " version=""1""" )
call stream.writeline( " xmlns=""http://xspf.org/ns/0/"">" )
call stream.writeline( "<trackList>" )
''-- Search for musique
set basefolder = fs.getfolder( "./" )
call search( basefolder )
''-- End Playlist
call stream.writeline( "</trackList>" )
call stream.close( )
''-- Search Folders Recursively
''--
function search( folder )

''-- Skip Crap
if( left( folder.name, 1 ) = "." ) then exit function

''-- Scan Files
call scan( folder.files )

''-- Traverse Sub-Folders
for each subfolder in folder.subfolders

call search( subfolder )

next
end function
''-- Scan Files
''--
function scan( files )

for each file in files

''-- Notice: I pass lazy reference params around
if( filter_file( file, _
title, _
creator, _
category, _
image, _
location ) ) then

call add_track( title, creator, category, image, location )

end if

next

end function
''-- Filter File
''--
function filter_file( file, title, creator, category, image, location )

''-- Ignore File by Default
filter_file = false

''-- Tokenize File Name/Path
extension = file_extension( file )
title = file_title ( file )
creator = file_creator ( file )
category = file_category ( file )
location = file_location ( file )
image = file_image ( file )

''-- Check now (at last!)
''-- add your own extension filters
if( extension = "mp3" ) then
filter_file = true
end if

end function

''-- Add Track
''--
function add_track( title, creator, category, image, location )
call stream.writeline( " <track>" )
call stream.writeline( " <title>" + title + "</title>" )
call stream.writeline( " <creator>" + category + "</creator>" )
''--call stream.writeline( " <category>" + category + "</category>" )
call stream.writeline( " <info>" + "'" + category + "'" +"</info>" )
call stream.writeline( " <image>" +"../" + image + "</image>" )
call stream.writeline( " <location>" + location + "</location>" )
call stream.writeline( " </track>" )
end function

''-- File Extension
''--
function file_extension( file )
''-- Last three chars
file_extension = right( file.name, 3 )
end function

''-- File Title
''--
function file_title( file )
'' Filename minus four
file_title = left( file.name, len( file.name ) - 4 )
end function

''-- Absolute to Reative Location
''--
function file_location( file )
''-- Remove base folder and tilt slashes (no url encoding)
relative = mid( file.path, len( basefolder.path ) + 2 )
file_location = replace( relative, "\", "/" )
end function

''-- Author / Creator / Artist
''--
function file_creator( file )
''-- basefolder\(((artist)))\album\song
tokens = split( file.path, "\" )
file_creator = tokens( ubound( tokens ) - 2 )
end function

''-- Category / Album
''--
function file_category( file )
''-- basefolder\artist\(((album)))\song
tokens = split( file.path, "\" )
file_category = tokens( ubound( tokens ) - 1 )
end function

''-- File Media Image
''--
function file_image( file )
''-- Assuming the same media.jpg for each file in the folder
relative = file_location( file )
file_image = replace( relative, file.name, "photo.jpg" )
end function

@Zino,

You had me fooled good. I saw playlist.php and thought you were using a php script from these forums. Well VBscript is OK.

Let me take a look and I'll post an updated script.

@Will
Never mind about the playlist generator, I fix it.
Thanks !

@Zino,

It's OK. I haven't worked with VBscript for a while, so it might be enjoyable to get away from the JavaScript for a few moments.

I'll fix up as much as I can and then you can test it and maybe "tweak" it a bit. :)

@Zino,

See, that wasn't so hard.

''--
''--
''-- jeneratiff / musique
''-- Stylianos Dritsas (C) 2007
''-- http://jeneratiff.com
''--
''-- License: Creative Commons License
''-- http://creativecommons.org/licenses/by-nc-sa/3.0/
''--
''-- Scripting Object

set fs = createobject( "Scripting.FileSystemObject" )

''-- Playlist File Stream
set stream = fs.createtextfile( "playlist.php", true )

''-- Search for musique
set basefolder = fs.getfolder( "./" )

''-- Begin Playlist
call stream.writeline( "<?xml version='1.0' encoding='UTF-8'?>" )
call stream.writeline( "<playlist version='1' xmlns='http://xspf.org/ns/0/'>" )
call stream.writeline( "  <trackList>" )
call search( basefolder )

''-- End Playlist
call stream.writeline( "  </trackList>" )
call stream.writeline( "</playlist>>" )
call stream.close( )

''-- Search Folders Recursively
''--
function search( folder )

''-- Skip Crap
if( left( folder.name, 1 ) = "." ) then exit function

''-- Scan Files
call scan( folder.files )

''-- Traverse Sub-Folders
for each subfolder in folder.subfolders

call search( subfolder )

next
end function
''-- Scan Files
''--
function scan( files )

for each file in files

''-- Notice: I pass lazy reference params around
if( filter_file( file, _
title, _
creator, _
category, _
image, _
location ) ) then

call add_track( title, creator, category, image, location )

end if

next

end function
''-- Filter File
''--
function filter_file( file, title, creator, category, image, location )

''-- Ignore File by Default
filter_file = false

''-- Tokenize File Name/Path
extension = file_extension( file )
title = file_title ( file )
creator = file_creator ( file )
category = file_category ( file )
location = file_location ( file )
image = file_image ( file )

''-- Check now (at last!)
''-- add your own extension filters
if( extension = "mp3" ) then
filter_file = true
end if

end function

''-- Add Track
''--
function add_track( title, creator, category, image, location )
call stream.writeline( "    <track>" )
call stream.writeline( "      <title>" + title + "</title>" )
call stream.writeline( "      <creator>" + category + "</creator>" )
''--call stream.writeline( "      <category>" + category + "</category>" )
call stream.writeline( "      <info>" + "'" + category + "'" +"</info>" )
call stream.writeline( "      <image>" +"../" + image + "</image>" )
call stream.writeline( "      <location>" + location + "</location>" )
call stream.writeline( "    </track>" )
end function

''-- File Extension
''--
function file_extension( file )
''-- Last three chars
file_extension = right( file.name, 3 )
end function

''-- File Title
''--
function file_title( file )
'' Filename minus four
file_title = left( file.name, len( file.name ) - 4 )
end function

''-- Absolute to Reative Location
''--
function file_location( file )
''-- Remove base folder and tilt slashes (no url encoding)
relative = mid( file.path, len( basefolder.path ) + 2 )
file_location = replace( relative, "\", "/" )
end function

''-- Author / Creator / Artist
''--
function file_creator( file )
''-- basefolder\(((artist)))\album\song
tokens = split( file.path, "\" )
file_creator = tokens( ubound( tokens ) - 2 )
end function

''-- Category / Album
''--
function file_category( file )
''-- basefolder\artist\(((album)))\song
tokens = split( file.path, "\" )
file_category = tokens( ubound( tokens ) - 1 )
end function

''-- File Media Image
''--
function file_image( file )
''-- Assuming the same media.jpg for each file in the folder
relative = file_location( file )
file_image = replace( relative, file.name, "photo.jpg" )
end function

To change the image folder, change this line:

call stream.writeline( "      <image>" + <strong>"../"</strong> + image + "</image>" )

right now it's set to go up one level in the directory tree: "../"
You can start with the filesystem root and specify the path: "/Media/Photos/"
You can go up one level in the directory tree and specify a folder: "../Photos/"
You can down in the directory tree: './Music/Photos/"

You can add an info URL by adding this near the top of the file:

''-- Info URL
info = "http://my.domain.com"

and changing this line:

call stream.writeline( "      <info>" + <strong>info</strong> + "</info>" )

Anything else, post here and I'll help you.

@Zino,

Looks like this:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
  <trackList>
    <track>
      <title>Daft Punk - Around The World</title>
      <creator>My Music</creator>
      <info>http://my.domain.com</info>
      <image>../photos/photo.jpg</image>
      <location>Daft Punk - Around The World.mp3</location>
    </track>
    <track>
      <title>Daft Punk - Harder, Better, Faster</title>
      <creator>My Music</creator>
      <info>http://my.domain.com</info>
      <image>../photos/photo.jpg</image>
      <location>Daft Punk - Harder, Better, Faster.mp3</location>
    </track>
    <track>
      <title>Daft Punk - Robot Rock</title>
      <creator>My Music</creator>
      <info>http://my.domain.com</info>
      <image>../photos/photo.jpg</image>
      <location>Daft Punk - Robot Rock.mp3</location>
    </track>
</trackList>
</playlist>

@Will,
Thanks a lot! it is all fixed now and I was able to put the player code into the <head>. All works fine except a small issues that I'm bringing up [url=http://www.jeroenwijering.com/?thread=6512]Here[/url]

can any one tel me a step by step by procedure to place the above code by @Will to generate xml from folder. i have image rotator on my site and i just want to pick up images from the folder and create an xml file which then can be used to display the images

@newbee,

First of all, do you want to use the Visual Basic script posted above or much more powerful, more fully developed PHP scripts. Most hosts provide support for PHP scripts, check with your host.

The Visual Basic script will generate a playlist from a local folder. You would then have to upload that playlist and the files to your host.

If you want to run the visual Basic script:

1) copy and paste the code from my post of 18.07.2007 into any text editor (Notepad, Wordpad), and then save it as text named playlist.vbs

2) find this line and change the playlist name from playlist.php to playlist.xml

set stream = fs.createtextfile( "playlist.php", true )

3) find this line and change mp3 to jpg

if( extension = "mp3" ) then

4) find this line and put ''-- (that's two single-quotes and two minus signs) at the beginning of the line to comment out the code (it won't be executed)
from this:

call stream.writeline( "      <image>" +"../" + image + "</image>" )

to this:

''--call stream.writeline( "      <image>" +"../" + image + "</image>" )

5) find this line and change it to have a link to your site OR comment it out (with ''-- ) if you don't want a link to your site.
from this:

call stream.writeline( " <info>" + "'" + category + "'" +"</info>" )

to this:

call stream.writeline( " <info>http://my.domain.com</info>" )

adjust "my.domain.com" to your site if you use the <info> link.

6) find this line and change category to creator:
from this:

call stream.writeline( " <creator>" + category + "</creator>" )

to this:

call stream.writeline( " <creator>" + creator + "</creator>" )

7) save the file as playlist.vbs in the directory where your images are or the parent directory if you have images in multiple sub-directories.

8) in Windows Explorer (NOT Internet Explorer) navigate to the directory where you saved playlist.vbs. Double-click on playlist.vbs. In a few seconds, there will be a file named "playlist.xml" in the same directory. Open "playlist.xml" with a text editor and examine it to see if it looks satisfactory.
It should look like this:

<?xml version='1.0' encoding='UTF-8'?>
<playlist version='1' xmlns='http://xspf.org/ns/0/'>
  <trackList>
    <track>
      <title>FirstImage</title>
      <creator>flowers</creator>
      <info>http://my.domain.com</info>
      <location>FirstImage.jpg</location>
    </track>
    <track>
      <title>Red Flowers</title>
      <creator>flowers</creator>
      <info>http://my.domain.com</info>
      <location>Red Flowers.jpg</location>
    </track>
    <track>
      <title>Roses</title>
      <creator>flowers</creator>
      <info>http://my.domain.com</info>
      <location>Roses.jpg</location>
    </track>
  <trackList>
<playlist>

Post back if you need more help. Code is always good. :)

@Will
You are a genius.....
I was trying to figure out all the possible things but never thought of posting a question. And now my problem is solved.

but one more thing
What i want to do is that i want the page to create the XML file.
in this way i just have to update the image folder.
and when the page which has the imagerotator will generate the xml and images will get generated.

just wanted to know if i can do this way

<td><div id="player1"><a ref="http://www.macromedia.com/go/getflashplayer" >Get the Flash Player</a> to see this player.</div> </td>
<script type="text/javascript">
var s2 = new SWFObject("imagerotator.swf","rotator","204","186","7");
s2.addVariable("file","playlist1.xml");
s2.addVariable("transition","random");
<!-- s2.addVariable("shownavigation","true"); -->
s2.addVariable("overstretch","true");
s2.write("player1");
</script>

in the above code can i change the line
s2.addVariable("file","playlist1.xml");

to

s2.addVariable("file","playlist.vbs");

I hope you can understand want i want to archive

and one more when i execute the vbs file on a perticular folder i gives me only thee files in the xml

and thanks again for the previous post you r a life saver
thanks i really appreciate it.
cheers

@newbeee,

You probably can't execute a Visual Basic script on your host.

To generate the playlist dynamically on a server, you should use the PHP playlist_generator scripts.

If you want to do that, post back.

@Will
Yes, i want to generate the paylist dynamically on the server.
can u help me!!

@Will
I have searched through out the forum but did not find any php playlist generator
can u help me with code to generate playlist on the server

cheers!!

@newbee,

Yeah, I'll give you my PHP code for an Image Rotator playlist generator. Right now I'm very busy, so please give me a day or two. :)

@Will,
Can you tel me any other thread where the Image Rotator Playlist Generator code will be found.

@newbee,

You can find it here:

<?php

/*
* This is a sample file that reads through a directory, filters the mp3/jpg/flv
* files and builds a playlist from it. After looking through this file, you'll
* probably 'get the idea' and'll be able to setup your own directory.
*/

// search for jpg files

$filter = ".jpg";
$pattern = '/\\' . $filter . '/';

// path to the directory you want to scan  ** no trailing slash **
// $directory = (isset($_GET["dir"])) ? strval($_GET["dir"]) : "C:/Images";
$directory = "C:/Media/Images";

// image URL  ** no trailing slash **
$imageurl = "http://my.domain.com/path-to-files";

// audio URL
$audiourl = "http://my.doamin.com/path-to-file/song.mp3";

// info URL
$infourl = "http://my.domain.com/";

// read through the directory and filter files to an array
@$d = dir($directory);
if (
$d)
{
  while(
$entry=$d->read())
  {
   
$ps = strpos(strtolower($entry), $filter);
    if (!(
$ps === false))
    {
     
$items[] = $entry;
    }
  }
 
$d->close();
 
sort($items);
}

// the playlist is built in an XSPF format
// first, we'll add an xml header and the opening tags...
header("content-type:text/xml;charset=utf-8");

echo

"<?xml version='1.0' encoding='UTF-8'?>
\n";
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo "  <title>Sample PHP Generated Playlist</title>\n";
echo "  <info>http://www.jeroenwijering.com/</info>\n";
echo "  <trackList>\n";

// ...then we loop through the array...
for($i=0; $i<sizeof($items); $i++)
{
  $title = preg_replace($pattern, '', $items[$i]);
  $title = preg_replace('/_/', ' ', $title);

  echo "    <track>\n";
  echo "      <title>" . $title . "</title>\n";
  echo "      <location>" . $imageurl . "/" . $items[$i] . "</location>\n";
  echo "      <link rel='audio'>" . $audiourl . "</link>\n";
  echo "      <info>" . $infourl . "</info>\n";
  echo "    </track>\n";
}

// ...and last we add the closing tags
echo " </trackList>\n";
echo "</playlist>\n";

/*
* That's it! You can feed this playlist to the SWF by setting this as it's 'file'
* parameter in your HTML page.
*/

?>

Adjust:

$directory
$imageurl
$audiourl
$infourl

Cheers (b) Mate

Excellent thanks a lot every thing working fine

thanks

@newbee,

You're welcome. Enjoy!(b)

Post a link if or when you have one.

@newbee,

You're welcome. Enjoy! (b)

Post a link, if or when you have one.

I tried this code and it creates an error on my server because of this line:
header("content-type:text/xml;charset=utf-8");
The error:

Warning: Cannot modify header information - headers already sent by (output started at /path-to/public_html/slideshow/playlist.php:2) in /path-to/public_html/slideshow/playlist.php on line 47

uncommenting this line makes the code work. any reason why i should try to keep it?

What you should do, is fix the error on line 47, that is causing an unwanted header to be sent.

This is line 47 - how do i fix it?

header("content-type:text/xml;charset=utf-8");

The error is somewhere before that line.

Call the playlist generator in your browser to see the actual error: http://my.domain.com/path/playlist_generator.php
Adjust the URI and filename as necessary to match yours.

@will

can you show the screen shot of the playlist for which you have generated the code??

thnx

Name: wazir muhammad irfan address: mouhalah broq khore markunja post office shigar tehsil shigar district skardu baltistan. Phone no: 05831470137, Mobile no: 03464661055, Mobile no: 03129990039 Email address: 1: wazir.maya@yahoo.com Email address 2: balti789@yahoo.com Email address 3 asifhaider60@yahoo.com Email address 4: shaziabatool26@yahoo.com Email address 5: irfan.balti@gmail.com Email address 6: shigri.ali@gmail.com Address: 2 Virtual university of pakistan shadman market lahore pakistan 54000

@ Will

hi hope u could help me im just trying to do somethign simple i wanna create an html page that takes all the pictures from a particular folder and shows them on the website

so what i mean is a folder where i could randomly deleat/add pictures into and go onto the web-page and c that new picture and so on... could u pls help me thx!