Page 1 of 1
Streaming Music
Posted: Wed May 14, 2008 7:09 pm
by aliasxneo
Is it possible to stream music with PHP? I'm looking to create an online radio script, nothing too advanced (just plays random music files) but am wondering how I would stream the music. I know I want to use PHP for the back-end for adding and editing the playlist, but streaming is something I've never done before. Can someone shed some light on this?
Re: Streaming Music
Posted: Wed May 14, 2008 7:20 pm
by Christopher
I think there as a php based streaming solution around somewhere. Have you searched? I think it may be pseudo-streaming, but it may do what you want.
Re: Streaming Music
Posted: Wed May 14, 2008 7:57 pm
by aliasxneo
arborint wrote:I think there as a php based streaming solution around somewhere. Have you searched? I think it may be pseudo-streaming, but it may do what you want.
I see a lot of stuff for streaming video (Flash etc.) but nothing with audio.
Re: Streaming Music
Posted: Wed May 14, 2008 9:21 pm
by Christopher
Audio streaming typically uses the same players as video players -- just no video window. Flash is commonly used for both.
Re: Streaming Music
Posted: Thu May 15, 2008 12:32 am
by aliasxneo
arborint wrote:Audio streaming typically uses the same players as video players -- just no video window. Flash is commonly used for both.
Well somehow I still havn't found anything. Most I found was something with Real Media Player which wouldn't work to my knowledge with live streaming (i.e I believe Real is just for one song at a time).
Re: Streaming Music
Posted: Thu May 15, 2008 1:32 am
by Kieran Huggins
Streaming is definitely possible with PHP, just fpassthru() the file. If you want to limit the bandwidth you can stream so much data and then sleep for a second, wash, rinse, repeat.
Re: Streaming Music
Posted: Thu May 15, 2008 9:22 am
by aliasxneo
Kieran Huggins wrote:Streaming is definitely possible with PHP, just fpassthru() the file. If you want to limit the bandwidth you can stream so much data and then sleep for a second, wash, rinse, repeat.
So how exactly does that work?
Code: Select all
<?php
header("Cache-Control: ");
header("Content-Type: audio/mpeg");
header("Content-Transfer-Encoding: binary");
$fp = fopen("Airbase.mp3", 'rb');
fpassthru($fp);
exit;
?>
This is what I got, and it almost seems to be working except it's only streaming like the first 2 seconds of the song. You can see it here:
http://youthapologetics.net/test/test.php
Any idea?