Jump to content

streaming m3u file generated by php


mattennant

Recommended Posts

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

[code]<?
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";
?>[/code]

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

[code]<?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';
}
?>[/code]

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.