/* * Copyright (c) sk89q <http://sk89q.therisenrealm.com> * Licensed under the GNU General Public License v3 */ require 'config.php'; require 'server.php'; require 'shoutcast.php'; require 'audiosource.php'; require 'http.php'; set_time_limit(0); $Server = new Server(); $AudioSource = new AudioSource(); $AudioSource->bitrate = $CONFIG['bitrate']; $AudioSource->encoder = $CONFIG['encoder_path']; $AudioSource->metadata_interval = $CONFIG['metadata_interval']; $AudioSource->populate_playlist($CONFIG['music_dir']); $AudioSource->open_next_file(); $Shoutcast = new Shoutcast(); $Shoutcast->server =& $Server; $Shoutcast->source =& $AudioSource; $Shoutcast->metadata_interval = $CONFIG['metadata_interval']; $Shoutcast->server_name = $CONFIG['server_name']; $Shoutcast->server_genre = $CONFIG['server_genre']; $Shoutcast->server_url = $CONFIG['server_url']; $Shoutcast->server_public = $CONFIG['server_public']; $Shoutcast->hook_to_server(); $HTTP = new HTTP(); $HTTP->server =& $Server; $HTTP->shoutcast =& $Shoutcast; $HTTP->hook_to_server(); $Server->listen();
<?php include 'shoutcast.php'; $s = new Shoutcast('10.211.55.3', '8000'); if (!$s->server_online()) { echo 'Server offline'; } else { if (0 == $s->get('STATION_STATUS')) { echo 'Transmition off'; } else { $format = '<strong>%s:</strong> %s <br />'; //Print Current Listeners printf($format, 'Current Listeners', $s->get('CURRENT_LISTENERS')); //Print Current Song printf($format, 'Current Song', $s->get('CURRENT_SONG')); //Print Song History if ($s->admin_mode()) { $str_history = ''; foreach ($s->get('SONG_HISTORY') as $song) { $str_history .= '<br />' . $song['TITLE']; } printf($format, 'Song History', $str_history); } } }
* You can set the shoutcast details in the constructor or the setDetails() method. * The constructor will call the setDetails method with the arguments that it receives. * * setDetails($host, $port = 8000, $pass = '', $stream = 1) * The port default is 8000 * The stream is default to 1, this will not affect shoutcast v.1 usage. * * Requirements * * cURL * PHP 5.3.3+ * */ require_once 'Shoutcast.php'; // No password and default stream id (1) $sc = new Shoutcast('example.com', 7309); //Load the basic stats if ($sc->getBasicStats()) { // can use the __get magic method echo $sc->songTitle; // can use the get method (the __get method just calls this one anyway) echo $sc->get('songtitle'); // whatever you pass to the two above methods will be put through strtoupper() // as all of the keys are uppercase // get the XML out of the object so you can do whatever you want with it $xml = $sc->getXML(); // you can then get the stats for a second server by setting the details again if ($sc->setDetails('anotherHost.com', 1234)->getBasicStats()) { echo $sc->songTitle; } else { echo $sc->getError();