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
https://forums.phpfreaks.com/topic/20567-streaming-m3u-file-generated-by-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.