Author: Horst Nogajski
Licence: GNU GPL (http://www.opensource.org/licenses/gpl-license.html)
Version: 1.0 (2005-01-06)
You can download the class at phpclasses.org!
UP (to the list)
Current version 1.0 supports direct connection to Shoutcast-Servers,
simple HTTP-Proxy-Connections and HTTP-Proxy-Connections with user:pass
Automatic handling of accidential connections to a stream instead to the HTML-Infopage!
(Maybe happen sometimes, if you automatically retrieve URLs from playlists and pass them to the class)
The class then try to connect to the server by it's root-dir and/or to the Shoutcast-Defaultport.
The class can be used in web-environment or with commandline-scripts.
When calling classinstance, you can switch on/off debugging, and optional define a socket-timeout in seconds:
- hn_shoutcast($http_debug=FALSE, $socket_timeout=10)
Now there is only one method needed to query a server and retrieve all available Information:
- query_URL($url, $proxy=NULL)
$url is the server or server:port-combination to query,
optional argument $proxy can be something like: http://proxyhost:port or http://username:password@proxyhost:port.
The method doesn't send username and password in plain-text, it only needs the argument passed in this way.
If the station is online, the class-var $online is TRUE, otherwise FALSE.
If query_URL has success and the station is online, we have all available Infos stored in array $info:
- 'Server Status' - 'Stream Status' - 'Stream Title' - 'Stream URL' - 'Content Type' - 'Bandwidth' - 'Stream Genre' - 'Current Song' - 'Listeners' - 'MaxListeners' - 'Listener Peak' - 'Average Listen Time' - 'Stream AIM' - 'Stream IRC' - 'Stream ICQ'
(And also all other infos what was served from the station.)
All empty fieldvalues in array $info becomes per default 'N/A'. This is set in class-var $NotAvailable. You can define another value if you like, (maybe FALSE).
With this extension you have easy access to each single information. If an Information is not available the value of class-var $NotAvailable is returned by the methods.
So, now it's up to you, to decide if you want access the infos in array $info['field name'] or by calling the below methods, ;-)
- is_online() - station() - url() - content_type() - genre() - song() - bandwidth() - listeners() - maxlisteners() - listenerpeak() - aim() - irc() - icq()