From Your Search

Dynamic M3U playlist with PHP and MySQL
0 comments      Added on 01/01/07 by Kris
Podcasters listen up. I wanted to create a playlist (M3U file) in a couple varieties, one: recent podcasts (the last 30) and two: all podcasts. You would think this would be a simple thing to do with PHP and MySQL . . . nope. WordPress users might find this handy.

I did succeed (recent playlist).

Here's how I got it done:

1) Add a mod_rewrite line to your .htaccess file that ends with '.m3u' like so:
RewriteRule ^playlist/all/playlist.m3u$ http://www.yourdomain.com/yourscript.php?type=$1
2) Create the PHP script to generate the M3U data structure:
a. connect to your MySQL database
b. query your live podcasts (the ones in your cms like WordPress not labled draft. You'll most likely need to know the data type it submits to this field in the database like '0' or '1')
c. pull up the post id, post title and podcast file
3) Lie to the browser by writing a header for an M3U file:
header("content-type: audio/x-mpegurl");
4) Write this line without 'echo' or 'print':
#EXTM3U
5) Create a loop to write your podcast id, podcast title and podcast URL

6) The M3U output, which you shouldn't see in the browser if you do this right (I know I saw it for about an hour) looks like:
#EXTM3U
#EXTINF:597,Betsy and her husband Kris Jan 01, 2007
http://www.croncast.com/show/597/cks-2007-01-01.mp3
#EXTINF:596,Betsy and her husband Kris Dec 29, 2006
http://www.croncast.com/show/596/cks-2006-12-29.mp3
I am not a super coder but this should be enough to get you going. And just in case that it isn't look below for the exact (well, nearly exact script that I am using).


  

Tags
  dynamic m3u  m3u php  m3u from php  m3u php mysql  dynamic m3u from php  



CLEAR SILICON CASE +BELT CLIP +CAR CHARGER for iPHONE
Current bid: $6.79 on eBay
FOR iPHONE iPod Touch 8G 16G Video CAR KIT MOUNT HOLDER
Current bid: $6.49 on eBay
See all 67,688 iPhone items on eBay.  



 
Leave a comment
Name:
Email:
Url:
Comment:
 
 
 
 
<< view all shows
 
 



Have us over



Scratch   Archive



PRADA LADIES ORANGE MESSENGER TOTE HANDBAG $940
Current bid: $449.99 on eBay


PRADA Brown Suede Loafers Shoes US 11.5 Men $650 NEW
Current bid: $399.99 on eBay


PRADA Black Patent Leather Boots US 12 Mens $440 NEW
Current bid: $309.99 on eBay


NEW PRADA BROWN CROCODILE WALLET SET 2 PCS
Current bid: $152.50 on eBay


Womens Black Prada Purse
Current bid: $51.00 on eBay

See all 8,518 Prada items on eBay.  
  June 2008 (7)
May 2008 (8)
April 2008 (11)
March 2008 (8)
February 2008 (10)
January 2008 (10)
December 2007 (6)
November 2007 (13)
October 2007 (12)
Sep. 2007 (11)
August 2007 (13)
July 2007 (11)
June 2007 (11)
May 2007 (13)
April 2007 (13)
February 2007 (10)
January 2007 (11)
December 2006 (13)
November 2006 (16)
October 2006 (12)
Sep. 2006 (10)
August 2006 (13)
July 2006 (14)
June 2006 (10)
May 2006 (12)
April 2006 (15)
March 2006 (9)
January 2006 (3)
December 2005 (4)
November 2005 (7)
October 2005 (13)
Sep. 2005 (13)
August 2005 (14)
July 2005 (7)
June 2005 (13)
May 2005 (13)
April 2005 (14)
March 2005 (13)
February 2005 (19)
January 2005 (21)
December 2004 (24)
November 2004 (18)