Old 1st September 2004, 03:46   #1
Dragnovich
Junior Member
 
Join Date: Jun 2003
Posts: 3
How to generate a dinamic playlist?

Hello Im trying to generate a dinamic play list file, using PHP. I want to have some MP3 files (200+) on the server, but I want to make a little script that take the hole list of mp3 files and ramdomly play 5 of the MP3. So far I find the "Unofficial M3U /PLS format" here in the forum, but if I upload the pls to the server. WinAmp (QuickTime & WindowsMediaPlayer) give me an error and no sound is listened.

So far I got this play list file:
code:

[playlist]
File1=mega001.mp3
Title1=Promo 1
Length1=30
File2=mega002.mp3
Title2=Promo 2
Length2=30
NumberOfEntries=2
Version=2



play.pls, mega001.mp3 & mega002.mp3 are in the same dir. And the server mime types are setup to:

audio/mpeg mpga mp2 mp3 m3u

Do I need to set up and special MIME for the PLS format?

If I access to the MP3 files directly the server "streams" them and the player starts and play automatically, but with the PLS file does not work at all.
http://server/mega001.mp3 (works)
http://server/mega002.mp3 (works)
http://server/play.pls (does not work)

In the PLS file I try putting the full URL and didn't work.

And when I sucessfully make the PLS work... what HEADERS do I need to send so the WinAmp (or any other player) take the Resoults as a PLS file??

I try:
code:

<?php
header("Content-disposition: attachment; filename=play.pls");
header("Content-type: text/plain");
?>
[playlist]
File1=mp3 - mega001.mp3
Title1=Everclear - So Much For The Afterglow
Length1=30
File2=mp3 - mega002.mp3
Title2=Weird Al - Everything You Know Is Wrong
Length2=30
NumberOfEntries=2
Version=2



First header forces the browser to download the file as play.pls, second send the file as a text. But that does not work too

Im doing something grong?

I try using M3U but is the same problem!
Dragnovich is offline   Reply With Quote
Old 1st September 2004, 05:06   #2
DJ Egg
Techorator
Winamp & Shoutcast Team
 
Join Date: Jun 2000
Posts: 35,881
MIME for .pls = audio/scpls
MIME for .m3u = audio/mpegurl (or audio/m3u)
DJ Egg is offline   Reply With Quote
Old 1st September 2004, 05:11   #3
drewbar
Sawg 2.0
Major Dude
 
Join Date: Mar 2004
Posts: 5,916
Mime type is audio/scpls or audio/mpegurl. Try that, should help.

Count with us!
Jan 1st, 12AM (PST, GMT -8) 2010 - 282,246
drewbar is offline   Reply With Quote
Old 28th December 2005, 07:58   #4
misteralexander
Junior Member
 
misteralexander's Avatar
 
Join Date: Jun 2005
Location: It's All On My Site . . .
Posts: 14
PLS with PHP

It took me awhile, but several forums (including winamp) and I managed to piece together a working PHP script that automatically generagtes a WORKING .pls file. It's great & I love it.

Here's what I've got:
PHP Code:
<?php 
// Playlist generation 
$playlist "[playlist]\n"
$dir "../"
// MY .MP3's ARE IN MY BASE DIRECTORY AND MY SCRIPT IS
// INSIDE "%BASEDIR%/GENERATION" SO I HAVE IT SET TO LOOK
// BACK ONE LEVEL TO FIND MY MUSIC. OTHERWISE SET THE $dir
// TO SOMETHING LIKE "MUSIC/" TO LOOK AHEAD ONE LEVEL.

$i 1

if((
$dh = @opendir($dir)) !== false

    
// Changing to pls file 
    
header("Content-Type: audio/x-scpls"); 
    
header("Content-Disposition: attachment; filename=\"WHATEVERYOUWANT.pls\""); 

    while((
$file = @readdir($dh)) !== false
    { 
        if(
$file != '.' && $file != '..'
        { 
            
$playlist .= 'File' $i++ . '=http://MP3LOCATION.com/' rawurlencode(basename($file)) . "\n"
        } 
    } 
    @
closedir($dh); 
    
$playlist .= 'NumberOfEntries=' $i
    
header("Content-Length: " strlen($playlist)); 
    
// output playlist 
    
exit($playlist); 

else 

    die(
'unable to generate playlist'); 

?>
email me and let me know if that worked. I constantly stream my music using Winamp...it's great, because I travel allot.

Last edited by misteralexander; 28th December 2005 at 08:30.
misteralexander is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Winamp > Winamp Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump