PHP: IceCast Object Class

In addition to modifying an old version of a ShoutCast PHP object to allow for communication with Shoutcast streaming audio servers, a similar object was created for the same communication with Icecast streaming audio servers. The IceCast object class was built off of the ShouCast object class, following the same coding practices. Many of the same functions are available in both objects, however, some differences in the data provided by the different server types makes for some functionality discrepancies.

Currently this object class is only designed to support single stream Icecast servers. Unlike the Shoutcast streaming service, Icecast can have multiple streams per instance of the program. Each stream is identified by a unique mount-point name. The IceCast returns the data for these streams in an ordered list. The object’s functions return the data associated with the first stream (or mount-point) in the list provided by the server.

Once the PHP class file has been included, the IceCast() function can be used to build a new IceCast object. Here’s some example code of how to make use of the object class:

$i = new IceCast();
$i->host = 'http://streamipordomain.com/';
$i->port = '8000'; //port stream is broadcast on
$i->passwd = 'adminPa$$'; //stats admin password

if($i->openstats()) {
  if($i->getStreamStatus()) {
    //stream is online and information loaded
  } else {
    //stream is offline
  }
} else {
  //server could not be connected to or is offline
}

Built along the same structure as the ShoutCast object, the IceCast object also offers reliable connections and a simple, easy use interface.

Comments:

CoronelN:
January 19th, 2011 2:01 pm

Hello mate, i am trying your class, but i always get as if the server was offline…

any advise ?
http://www.orderofdoom.com/downloads/radio/lp.php

Leave a Comment

 

Trackback URL

http://www.minded.ca/default/2009-09-25/php-icecast-object-class/trackback/