For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > April 2005 > Streaming MP3's like a radio station?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Streaming MP3's like a radio station?
John Patrick

2005-04-29, 8:56 pm

Here's my site: http://www.motorcityrock.com

I have a streaming audio feature set up using a M3u file and a bunch of
MP3's: http://www.motorcityrock.com/mcr_radio/mcr_radio.html. When the
visitor clicks on the link the M3u kicks in and the songs play in the
pre-determined order. That works great, but everytime a visitor clicks the
link the songs start from the beginning. Is there a simple way (using
PHP or?) to keep the M3u "running" in the background all the time so
that all visitors will hear the same song at the same time...just like a
traditional radio station?

Thanks!

jp


Oli Filth

2005-04-29, 8:56 pm

John Patrick wrote:
> Here's my site: http://www.motorcityrock.com
>
> I have a streaming audio feature set up using a M3u file and a bunch of
> MP3's: http://www.motorcityrock.com/mcr_radio/mcr_radio.html. When the
> visitor clicks on the link the M3u kicks in and the songs play in the
> pre-determined order. That works great, but everytime a visitor clicks the
> link the songs start from the beginning. Is there a simple way (using
> PHP or?) to keep the M3u "running" in the background all the time so
> that all visitors will hear the same song at the same time...just like a
> traditional radio station?
>


MP3s don't stream. An M3U is just a playlist file, downloaded to the
user's computer and used by Winamp or whatever to determine what files
to play in what order.


--
Oli
John Patrick

2005-04-30, 3:57 am

I know that. I'm trying to make the M3U file dynamic somehow so that the
songs are rotating.

jp


"Oli Filth" <catch@olifilth.co.uk> wrote in message
news:ezyce.180$l37.55@newsfe4-gui.ntli.net...
> John Patrick wrote:
>
> MP3s don't stream. An M3U is just a playlist file, downloaded to the
> user's computer and used by Winamp or whatever to determine what files to
> play in what order.
>
>
> --
> Oli



SpoonfulofTactic@gmail.com

2005-04-30, 3:57 am

Sure, that is possible.

Given that you generate an array "$songs" of the song "name", "length"
in seconds, and "location", then it is easy:

the M3U format is as follows:

1 header("Content-type: audio/x-mpegurl");
2
3 echo "#EXTM3U\n";
4 foreach($songs as $song)
5 {
4 echo "#EXTINF:".$song['length'].",".$song['name']."\n";
5 echo $song['location']."\n";
6 }

SpoonfulofTactic@gmail.com

2005-04-30, 3:57 am

Ok, while that works, i have whipped up a more... "robust" example for
you.

I am not trying to show you how to generate the array, but rather how
to make this playlist compatible for downloading.

http://nerdfestlan.com/m3u.php.txt

John Patrick

2005-04-30, 3:57 am

thanks. I'll give it a try.


<SpoonfulofTactic@gmail.com> wrote in message
news:1114821012.050959.19680@g14g2000cwa.googlegroups.com...
> Ok, while that works, i have whipped up a more... "robust" example for
> you.
>
> I am not trying to show you how to generate the array, but rather how
> to make this playlist compatible for downloading.
>
> http://nerdfestlan.com/m3u.php.txt
>



John Patrick

2005-04-30, 3:57 am

OK, that works great...but it works basically the same as what I have here:
http://www.motorcityrock.com/mcr_radio/mcr_radio.html

I'd like it to act more like a regular radio station, whereas the songs
continue to play (rotate) even if no one is listening. Everyone that is
listening at the same time would be hearing the same thing...like live
radio. Your example works good, but everyone still hears the first song
first. Does that make sense?

jp


<SpoonfulofTactic@gmail.com> wrote in message
news:1114821012.050959.19680@g14g2000cwa.googlegroups.com...
> Ok, while that works, i have whipped up a more... "robust" example for
> you.
>
> I am not trying to show you how to generate the array, but rather how
> to make this playlist compatible for downloading.
>
> http://nerdfestlan.com/m3u.php.txt
>



SpoonfulofTactic@gmail.com

2005-04-30, 3:56 pm


John Patrick wrote:
> OK, that works great...but it works basically the same as what I have

here:
> http://www.motorcityrock.com/mcr_radio/mcr_radio.html
>
> I'd like it to act more like a regular radio station, whereas the

songs
> continue to play (rotate) even if no one is listening. Everyone that

is
> listening at the same time would be hearing the same thing...like

live
> radio. Your example works good, but everyone still hears the first

song
> first. Does that make sense?
>
> jp



Yes that makes sense but, as i said, my script assumes you generate the
$songs array in the order you want.

If you had a database set up with the song names, it would be easy to
give you an example. But since I have no clue as to what all songs you
will be using (other than those from your page) I am unable to give you
a complete and functioning script.

So, here is what I'll do: as soon as i get back to my development
comp, i will try to whip up an example more tailored to your needs.
(Even though, in doing this, I am violating my rule that i dont write
whole scripts for people.)

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com