Minded Systems

PHP: ShoutCast Object Class

In recent weeks, a large portion of development time and resources have been used in creating a few different media services, most of which are online. In doing this we found it necessary to create object classes for communications with the media server types that we would be connecting to.

The first, and most commonly used one is the ShoutCast object class. A special thanks on this object class goes to the original creator, Henrik Malmberg. The original object class was created back in 2002 and distributed under the GNU GPL License agreement. Fortunately for our developers, the majority of the original object class was able to be left in tact and remained functional with updated shoutcast server systems of today. A few small modifications were made to update and make it compatible with current Shoutcast server data XML.

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

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

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

Once the stream data has been loaded, a variety of other functions are available for retrieving the required data. A full function list will be added to this post shortly.

Reliable connections, easy use and simple interface; the class is a great script solution for gathering Shoutcast data. Its a great solution for getting current steam information onto websites, into analytics databases, and many others.

Please provide a valid email address

Trackback URL

http://www.minded.ca/2009-09-24/php-shoutcast-object-class/trackback/

  • […] Minded Software Solutions Web development and software services « PHP: ShoutCast Object Class […]

  • […] solutions will be needed to ensure successful integration into existing systems. Using both the ShoutCast object class and the IceCast object class as building models, a simple PHP object class has been built for basic […]