shoutcast class
There is a new version of this script!Please do not use / download this script unless your webserver only supports PHP4 (and not PHP5)
The new version can be found
here
With these 3 lines:
<?php
$display_array = array("Stream Title", "Stream Genre", "Stream URL", "Current Song");
$radio = new Radio("207.200.96.226:8048");
$data_array = $radio->getServerInfo($display_array);
?>
We got the following data (output of
print_r($data_array);)
Array
(
[0] => Radio Paradise - DJ-mixed modern & classic rock, world, electronica & more - info: radioparadise.com
[1] => eclectic rock
[2] => http://www.radioparadise.com
[3] => Air - Talisman
)
The same results, but displayed in a nicer way:
| Stream Title: |
Radio Paradise - DJ-mixed modern & classic rock, world, electronica & more - info: radioparadise.com |
| Stream Genre: |
eclectic rock |
| Stream URL: |
http://www.radioparadise.com |
| Current Song: |
Air - Talisman |
Getting the Playlist History
We already have the object
$radio, so with 1 extra line, we can get an overview of the songs that have been played:
<?php
$radio->getHistoryTable("/played.html", "<b>Played At</b>", "<b>Song</b>", "songOverview");
?>
The first argument indicates where the history-page is located (usually
/played.html, the others are optional.
The second and third can be used to put text at the top of the list. The fourth to give the table a class name that you can define in your stylesheet.
Using this stylesheet:
<style type="text/css">
.songOverview {
width:100%;
border:1px solid black;
background-color: #EEE;
}
.songOverview TD {
padding: 1px 10px 1px 1px;
}
</style>
the result of all this is:
| Played At | Song |
| 02:13:11 | Air - Talisman |
| 02:12:57 | Radio Paradise - Commercial-Free, Listener-Supported |
| 02:08:40 | Boy & Bear - Feeding Line |
| 02:03:25 | Active Child - Hanging On |
| 02:00:36 | The Beatles - Tomorrow Never Knows |
| 01:59:54 | Radio Paradise - Commercial-Free, Listener-Supported |
| 01:54:53 | Al DiMeola - Mediterranean Sundance |
| 01:52:06 | Los Lobos - La Bamba |
| 01:48:04 | Wall Of Voodoo - Mexican Radio |
| 01:44:27 | Kirsty MacColl - In These Shoes? |
| 01:44:25 | Kirsty MacColl - In These Shoes? |
| 01:40:14 | Kali - Me Ki Sa Oule |
| 01:37:06 | Spirit - Fresh Garbage |
| 01:36:45 | Radio Paradise - Commercial-Free, Listener-Supported |
| 01:32:56 | Arctic Monkeys - She`s Thunderstorms |
| 01:25:52 | Super Furry Animals - Run! Christian, Run! |
| 01:19:56 | Rickie Lee Jones - Running From Mercy |
| 01:19:38 | Radio Paradise - Commercial-Free, Listener-Supported |
| 01:16:43 | Eliza Gilkyson - Looking for a Place |
| 01:13:22 | The Decemberists - Summersong |
Or, if you just want to have them in an array:
<?php
print_r($radio->getHistoryArray("/played.html"));
?>
Array
(
[1] => Array
(
[time] => 02:13:11
[track] => Air - Talisman
)
[2] => Array
(
[time] => 02:12:57
[track] => Radio Paradise - Commercial-Free, Listener-Supported
)
[3] => Array
(
[time] => 02:08:40
[track] => Boy & Bear - Feeding Line
)
[4] => Array
(
[time] => 02:03:25
[track] => Active Child - Hanging On
)
[5] => Array
(
[time] => 02:00:36
[track] => The Beatles - Tomorrow Never Knows
)
[6] => Array
(
[time] => 01:59:54
[track] => Radio Paradise - Commercial-Free, Listener-Supported
)
[7] => Array
(
[time] => 01:54:53
[track] => Al DiMeola - Mediterranean Sundance
)
[8] => Array
(
[time] => 01:52:06
[track] => Los Lobos - La Bamba
)
[9] => Array
(
[time] => 01:48:04
[track] => Wall Of Voodoo - Mexican Radio
)
[10] => Array
(
[time] => 01:44:27
[track] => Kirsty MacColl - In These Shoes?
)
[11] => Array
(
[time] => 01:44:25
[track] => Kirsty MacColl - In These Shoes?
)
[12] => Array
(
[time] => 01:40:14
[track] => Kali - Me Ki Sa Oule
)
[13] => Array
(
[time] => 01:37:06
[track] => Spirit - Fresh Garbage
)
[14] => Array
(
[time] => 01:36:45
[track] => Radio Paradise - Commercial-Free, Listener-Supported
)
[15] => Array
(
[time] => 01:32:56
[track] => Arctic Monkeys - She`s Thunderstorms
)
[16] => Array
(
[time] => 01:25:52
[track] => Super Furry Animals - Run! Christian, Run!
)
[17] => Array
(
[time] => 01:19:56
[track] => Rickie Lee Jones - Running From Mercy
)
[18] => Array
(
[time] => 01:19:38
[track] => Radio Paradise - Commercial-Free, Listener-Supported
)
[19] => Array
(
[time] => 01:16:43
[track] => Eliza Gilkyson - Looking for a Place
)
[20] => Array
(
[time] => 01:13:22
[track] => The Decemberists - Summersong
)
)
(as you can see this function only has the first argument)
Try it yourself with the form below:
Of course, the data that you enter has to be of an existing station.
You can find them in the
shoutcast list
NOTE: Don't link to m3u (playlist) files!. It won't work
Last, but not least, here's a copy-paste script to help you get started:
To get this to work you need to:
- download the shoutcast-class source file
- save this script in a file and put it in the same folder (on a webserver that supports php of course!)
- optinally enter another ip (and port) on line 3 and 4 of this script
- open it in a web-browser of your choice