Jump to content


Photo

streaming m3u file generated by php


  • Please log in to reply
3 replies to this topic

#1 mattennant

mattennant
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 12 September 2006 - 11:31 PM

Hello there i've been struggling with this for a while now and wonder if anyone out there can help me out.

I'm trying to create an m3u file to stream music in a kind of radio player. I want the list of mp3's to come from my database music uploads.

I've managed to generate the m3u file when manually entering the mp3 paths within a php file

see code below

<?
header("Content-Type: audio/mpegurl");
header("Content-Disposition: attachment; filename=playlist.m3u");
print "http://www.myurl.co.uk/nowax/uploads/track1.mp3\r\n";
print "http://www.myurl.co.uk/nowax/uploads/track2.mp3\r\n";
?>


on the back of this sucess i tried to populate the mp3 paths from the relevent row in the database (see below)

<?php require_once('../../connections_handcode/handcode.php'); ?>
<?php
header("Content-Type: audio/mpegurl");
header("Content-Disposition: attachment; filename=playlist.m3u");
$query = "SELECT track_upload  FROM music_uploads";
$result = @mysql_query ($query);
if  ($result){
while ($row = mysql_fetch_array($result, MYSQL_NUM)){
echo'http://www.myurl.co.uk$row[0]'."\n";
}
}else{
echo'error';
}
?>

I believe, although i'm not certain that the above code, does not put each mp3 on a seperate line as i need to for the generated m3u file.

I hope this is something simple

thanks in anticipation

matthew

#2 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 12 September 2006 - 11:43 PM

Your single quotes are what are killing you:
echo'http://www.myurl.co.uk$row[0]'."\n";
-$row[0] not translated to value
-replace single quotes with double quotes
echo "http://www.myurl.co.uk$row[0]" ."\n";


#3 mainewoods

mainewoods
  • Members
  • PipPipPip
  • Advanced Member
  • 685 posts
  • LocationMaine

Posted 12 September 2006 - 11:45 PM

you're missing a '/' after '.uk' as well

#4 mattennant

mattennant
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 12 September 2006 - 11:51 PM

that's the one - thanks so much, i can go to sleep happy now




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users