PDA

View Full Version : Stream music from .php



queerfm
12-30-2007, 05:39 PM
Hi guys i just fond out that http://www.dnbradio.com was able to get there radio station streaming on iphones
http://www.dnbradio.com/iphone/ and it works, they are using a PHP

take a listen to there stream
http://www.dnbradio.com/iphone/stream.php?server=master.dnbradio.com&port=9050

more information @ http://blog.fuexy.com/2007/12/02/shoutcast-on-iphone-continued/
What i am wondering is HOW, can any one help.

Thank you

djr33
12-30-2007, 07:59 PM
Well, the details aren't clear to me, and I'm not sure where you can find the information on them, but the basic answer is that by sending out header data setting any sort of file, you can then output any file you'd like. A content-type header can set the data as html (this is the default, so no need to do so), an image, a text document, or really anything else you'd want.

So-- 1. figure out the right content-type header; 2. simply stream the content through the page. readfile($path) will just grab the contents of $path and output them directly to the user. That's the most basic.

queerfm
12-31-2007, 12:22 AM
this is what i have however its not working



<?php
$filename = "http://queersperm.com:8080";
$filesize = filesize($filename);
$mime_type = 'audio/mpeg';

header("Expires: Mon, 26 Nov 1962 00:00:00 GMT");
header("Last-Modified: " . gmdate("D,d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, private, must-revalidate, max-
age=0");
header("Pragma: no-cache");
header('Content-Length: '.$filesize);
header('Content-Type: '.$mime_type);
header('Content-Disposition: attachment;
filename="'.basename($filename).'"');

$fp = fopen($filename,"r");
while (!feof($fp)) {
echo fread($fp, 8192);
}
fclose($fp);
?>