Page 1 of 3

Shoutcast radio....

Posted: Thu May 04, 2006 8:15 am
by Daz wilde
Hi All!!! Just ready for setting up a radio on my board, its gonna be varuis dj streaming so i think shoutcast is the tool i'll need but is there a mod for intergrating it in with phpbb....

I was ideally after something like in this thread:

http://www.phpbbhacks.com/forums/viewto ... =shoutcast

Cheers!

Posted: Thu May 04, 2006 4:06 pm
by deejaybet
do you have shoutcast on your server, of yes pleae pm me as i am looking to get shoutcast on my own server too :)

Posted: Fri May 05, 2006 3:33 pm
by Daz wilde

Posted: Fri May 05, 2006 8:45 pm
by Daz wilde
Someone must know a mod like this???

Posted: Fri May 05, 2006 9:41 pm
by Ramon Fincken
I ve done this mod like this: http://www.rgtunez.co.uk/forum/

Here's the script:

file: shoutcastparser.php

Code: Select all

<?php
// Ramon Fincken, Phpbbinstallers.com
// Changed all Echo's to $shoutcast_phpbb_output .=
// shoutcastxml.php

// A SHOUTcast XML parser for PHP and Apache
// Copyright Peter Manchester B.Sc.
// All rights reserved
// 20th October 2002
// Web: www.petermanchester.co.uk
// Email: peter@petermanchester.co.uk

// turn off error reporting
error_reporting(0);

// DEBUG constant can be set to provide extra output when required
define ("DEBUG", "0");

// parameters for your SHOUTcast server - ** YOU WILL NEED TO CHANGE THESE **
$shoutcast_host = 'rgtunez.co.uk';  // SHOUTcast station url
$shoutcast_port = '8002';      // SHOUTcast station port number
$shoutcast_password = '';  // SHOUTcast password
$shoutcast_url = "http://" . $shoutcast_host . ':' . $shoutcast_port . "/listen.pls";
// end of parameters for your SHOUTcast server

// timeout period in seconds while contacting station
$fsock_time_out = 1;
// error number to be returned
$fsock_error_number = 0;
// error text to be returned
$fsock_error_text = "";

// an associative array to store the items we are interested in
$shoutcast_data = array('streamstatus' => '',
                        'bitrate' => '', 
                        'currentlisteners' => '', 
                        'maxlisteners' => '',
                        'servertitle' => '', 
                        'songtitle' => '');

$shoutcast_xml = "";

global $shoutcast_data, $shoutcast_xml_element;

if (!function_exists('startElement')) {

  // start element handler for xml parser
  function startElement($parser, $name, $attrs) {
      global $shoutcast_xml_element;
      // track which xml element is being parsed
      $shoutcast_xml_element = strtolower($name);
  }

}

if (!function_exists('endElement')) {

  // end element handler for xml parser
  function endElement($parser, $name) {
      global $shoutcast_xml_element;
      // forget which xml element was being parsed
      $shoutcast_xml_element = '';
  }
}

if (!function_exists('handleData')) {

  // character data handler for xml parser
  function handleData($parser, $data) {
      global $shoutcast_data, $shoutcast_xml_element;
      $shoutcast_data[$shoutcast_xml_element] .= $data;
  }
}

if (!function_exists('defaultHandler')) {

  // default handler
  function defaultHandler($parser, $data) {}
}

//open socket connection to the shoutcast server 
$shoutcast_fp = fsockopen($shoutcast_host,
                          $shoutcast_port, 
                          $fsock_error_number,
                          $fsock_error_text,
                          $fsock_time_out);

// check that the socket is open before proceeding
if($shoutcast_fp) {

    // socket connection is established, so the station is on-line

    // set 1 second timeout for communication with the station
    // stream_set_timeout($shoutcast_fp, 1);
    
    // build a string containing an HTTP request to your SHOUTcast server
    $shoutcast_httpreq = "GET /admin.cgi?pass=$shoutcast_password&mode=viewxml
      HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n";

    // send HTTP request to shoutcast server
    fputs($shoutcast_fp, $shoutcast_httpreq);

    // read entire xml output stream
    while(!feof($shoutcast_fp)) {
        $shoutcast_xml .= fgets($shoutcast_fp, 1000);
    }
  
    // close the socket now we no longer need it
    fclose($shoutcast_fp);

    // if we have got some XML back  then we need to strip away some
    // stuff that we don't need  
    if ($shoutcast_xml != '')
        $shoutcast_xml = strstr($shoutcast_xml, '<SHOUTCASTSERVER>');

    // create an instane of the EXPAT XML parser
    $xml_parser = xml_parser_create();

    // set element start and end element handler functions
    xml_set_element_handler($xml_parser, 'startElement', 'endElement');

    // set character data handler function
    xml_set_character_data_handler($xml_parser, 'handleData');

  xml_set_default_handler($xml_parser, 'defaultHandler');
  
    // activate the XML parser
  $parsed = xml_parse($xml_parser, $shoutcast_xml, 1);

    // some debugging code
    if (DEBUG) {
        $shoutcast_phpbb_output .= $shoutcast_xml;
        print_r ($shoutcast_data);
    }

    // check that the parsing operation worked correctly
    if ($parsed) {

        // it worked, so report the station status
        if ($shoutcast_data['streamstatus'] == '1') {
    
        // streaming content is available
        $shoutcast_phpbb_output .= '<p>';
        $shoutcast_phpbb_output .= $shoutcast_data['servertitle'];
        $shoutcast_phpbb_output .= '<br />Streaming at ';
        $shoutcast_phpbb_output .= $shoutcast_data['bitrate'];
        $shoutcast_phpbb_output .= ' kbps.</p>';
        $shoutcast_phpbb_output .= '<p>Currently playing: ';
        $shoutcast_phpbb_output .= $shoutcast_data['songtitle'];
        $shoutcast_phpbb_output .= '</p>';
        $shoutcast_phpbb_output .= '<p>Current listeners: ';
        $shoutcast_phpbb_output .= $shoutcast_data['currentlisteners'];
        $shoutcast_phpbb_output .= ' (only ';
        $shoutcast_phpbb_output .= $shoutcast_data['maxlisteners'];
        $shoutcast_phpbb_output .= ' allowed).</p>';
        if (intval($shoutcast_data['currentlisteners']) 
             < intval($shoutcast_data['maxlisteners'])) {
             $shoutcast_phpbb_output .= "<p>If you have Real Player installed, then ";
             $shoutcast_phpbb_output .= "click the Play button on the console above. ";
             $shoutcast_phpbb_output .= "Otherwise, to listen using Winamp ";
             $shoutcast_phpbb_output .= "click <a href=\"$shoutcast_url\">here</a>.</p>";
        } else {
             $shoutcast_phpbb_output .= "<p>Please wait until another listener can be added.</p>";
        }
        } else {

            // no streaming content is available
            $shoutcast_phpbb_output .= '<p>Radio is currently offline.</p>';
        }
        
    }
    else {
        // parsing failed
      if (DEBUG) {
          $shoutcast_phpbb_output .= 'XML Parser reported the following error:' . '<br />';
          $shoutcast_phpbb_output .= xml_error_string(xml_get_error_code($xml_parser)) . ' in line ';
          $shoutcast_phpbb_output .= xml_get_current_line_number($xml_parser) . '<br />';
      }
    }

    // the xml parser is no longer required
    xml_parser_free($xml_parser);

} else {

    // socket connection could not be established
    $shoutcast_phpbb_output .= '<p>The station is offline.</p>';
}

?>

OPEN

Code: Select all

index.php
FIND

Code: Select all

$template->pparse('body');
BEFORE, ADD

Code: Select all

// shoutcast Panel - START
// MOD Ramon Fincken, Phpbbinstallers.com
include_once($phpbb_root_path . 'shoutcastparser.'.$phpEx);
	     	$template->assign_block_vars('chield', array(   
	     	"SHOUTCAST_PHPBB_OUTPUT" => $shoutcast_phpbb_output));  
// MOD Ramon Fincken

// shoutcast - END
OPEN

Code: Select all

templates/[yourtemplatename]/index_body.tpl
ADD

Code: Select all

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="forumline"><tr><td>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="catHead" colspan="2" height="28"><span class="cattitle">Radio</span></td>
</tr>
<tr><td class="row1" align="left"><p class="genmed">

<!-- BEGIN shoutcastparser -->
{shoutcastparser.SHOUTCAST_PHPBB_OUTPUT}
<!-- END shoutcastparser --> 

<br /><br /></p></td></tr>
</table>


</td></tr></table>

DIY INSTRUCTIONS

Code: Select all

#edit
#// parameters for your SHOUTcast server - ** YOU WILL NEED TO CHANGE THESE **
#$shoutcast_host = 'rgtunez.co.uk';  // SHOUTcast station url
#$shoutcast_port = '8002';      // SHOUTcast station port number
#$shoutcast_password = '';  // SHOUTcast password
#$shoutcast_url = "http://" . $shoutcast_host . ':' . $shoutcast_port . "/listen.pls";
#// end of parameters for your SHOUTcast server

Posted: Sat May 06, 2006 3:24 am
by chrisb123
you mean something like this? www.4-djs.co.uk/board/index.php

Posted: Mon May 08, 2006 8:42 am
by Daz wilde
Ramon Fincken wrote: I ve done this mod like this: http://www.rgtunez.co.uk/forum/

Here's the script:

file: shoutcastparser.php

Code: Select all

<?php
// Ramon Fincken, Phpbbinstallers.com
// Changed all Echo's to $shoutcast_phpbb_output .=
// shoutcastxml.php

// A SHOUTcast XML parser for PHP and Apache
// Copyright Peter Manchester B.Sc.
// All rights reserved
// 20th October 2002
// Web: www.petermanchester.co.uk
// Email: peter@petermanchester.co.uk

// turn off error reporting
error_reporting(0);

// DEBUG constant can be set to provide extra output when required
define ("DEBUG", "0");

// parameters for your SHOUTcast server - ** YOU WILL NEED TO CHANGE THESE **
$shoutcast_host = 'rgtunez.co.uk';  // SHOUTcast station url
$shoutcast_port = '8002';      // SHOUTcast station port number
$shoutcast_password = '';  // SHOUTcast password
$shoutcast_url = "http://" . $shoutcast_host . ':' . $shoutcast_port . "/listen.pls";
// end of parameters for your SHOUTcast server

// timeout period in seconds while contacting station
$fsock_time_out = 1;
// error number to be returned
$fsock_error_number = 0;
// error text to be returned
$fsock_error_text = "";

// an associative array to store the items we are interested in
$shoutcast_data = array('streamstatus' => '',
                        'bitrate' => '', 
                        'currentlisteners' => '', 
                        'maxlisteners' => '',
                        'servertitle' => '', 
                        'songtitle' => '');

$shoutcast_xml = "";

global $shoutcast_data, $shoutcast_xml_element;

if (!function_exists('startElement')) {

  // start element handler for xml parser
  function startElement($parser, $name, $attrs) {
      global $shoutcast_xml_element;
      // track which xml element is being parsed
      $shoutcast_xml_element = strtolower($name);
  }

}

if (!function_exists('endElement')) {

  // end element handler for xml parser
  function endElement($parser, $name) {
      global $shoutcast_xml_element;
      // forget which xml element was being parsed
      $shoutcast_xml_element = '';
  }
}

if (!function_exists('handleData')) {

  // character data handler for xml parser
  function handleData($parser, $data) {
      global $shoutcast_data, $shoutcast_xml_element;
      $shoutcast_data[$shoutcast_xml_element] .= $data;
  }
}

if (!function_exists('defaultHandler')) {

  // default handler
  function defaultHandler($parser, $data) {}
}

//open socket connection to the shoutcast server 
$shoutcast_fp = fsockopen($shoutcast_host,
                          $shoutcast_port, 
                          $fsock_error_number,
                          $fsock_error_text,
                          $fsock_time_out);

// check that the socket is open before proceeding
if($shoutcast_fp) {

    // socket connection is established, so the station is on-line

    // set 1 second timeout for communication with the station
    // stream_set_timeout($shoutcast_fp, 1);
    
    // build a string containing an HTTP request to your SHOUTcast server
    $shoutcast_httpreq = "GET /admin.cgi?pass=$shoutcast_password&mode=viewxml
      HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n";

    // send HTTP request to shoutcast server
    fputs($shoutcast_fp, $shoutcast_httpreq);

    // read entire xml output stream
    while(!feof($shoutcast_fp)) {
        $shoutcast_xml .= fgets($shoutcast_fp, 1000);
    }
  
    // close the socket now we no longer need it
    fclose($shoutcast_fp);

    // if we have got some XML back  then we need to strip away some
    // stuff that we don't need  
    if ($shoutcast_xml != '')
        $shoutcast_xml = strstr($shoutcast_xml, '<SHOUTCASTSERVER>');

    // create an instane of the EXPAT XML parser
    $xml_parser = xml_parser_create();

    // set element start and end element handler functions
    xml_set_element_handler($xml_parser, 'startElement', 'endElement');

    // set character data handler function
    xml_set_character_data_handler($xml_parser, 'handleData');

  xml_set_default_handler($xml_parser, 'defaultHandler');
  
    // activate the XML parser
  $parsed = xml_parse($xml_parser, $shoutcast_xml, 1);

    // some debugging code
    if (DEBUG) {
        $shoutcast_phpbb_output .= $shoutcast_xml;
        print_r ($shoutcast_data);
    }

    // check that the parsing operation worked correctly
    if ($parsed) {

        // it worked, so report the station status
        if ($shoutcast_data['streamstatus'] == '1') {
    
        // streaming content is available
        $shoutcast_phpbb_output .= '<p>';
        $shoutcast_phpbb_output .= $shoutcast_data['servertitle'];
        $shoutcast_phpbb_output .= '<br />Streaming at ';
        $shoutcast_phpbb_output .= $shoutcast_data['bitrate'];
        $shoutcast_phpbb_output .= ' kbps.</p>';
        $shoutcast_phpbb_output .= '<p>Currently playing: ';
        $shoutcast_phpbb_output .= $shoutcast_data['songtitle'];
        $shoutcast_phpbb_output .= '</p>';
        $shoutcast_phpbb_output .= '<p>Current listeners: ';
        $shoutcast_phpbb_output .= $shoutcast_data['currentlisteners'];
        $shoutcast_phpbb_output .= ' (only ';
        $shoutcast_phpbb_output .= $shoutcast_data['maxlisteners'];
        $shoutcast_phpbb_output .= ' allowed).</p>';
        if (intval($shoutcast_data['currentlisteners']) 
             < intval($shoutcast_data['maxlisteners'])) {
             $shoutcast_phpbb_output .= "<p>If you have Real Player installed, then ";
             $shoutcast_phpbb_output .= "click the Play button on the console above. ";
             $shoutcast_phpbb_output .= "Otherwise, to listen using Winamp ";
             $shoutcast_phpbb_output .= "click <a href=\"$shoutcast_url\">here</a>.</p>";
        } else {
             $shoutcast_phpbb_output .= "<p>Please wait until another listener can be added.</p>";
        }
        } else {

            // no streaming content is available
            $shoutcast_phpbb_output .= '<p>Radio is currently offline.</p>';
        }
        
    }
    else {
        // parsing failed
      if (DEBUG) {
          $shoutcast_phpbb_output .= 'XML Parser reported the following error:' . '<br />';
          $shoutcast_phpbb_output .= xml_error_string(xml_get_error_code($xml_parser)) . ' in line ';
          $shoutcast_phpbb_output .= xml_get_current_line_number($xml_parser) . '<br />';
      }
    }

    // the xml parser is no longer required
    xml_parser_free($xml_parser);

} else {

    // socket connection could not be established
    $shoutcast_phpbb_output .= '<p>The station is offline.</p>';
}

?>

OPEN

Code: Select all

index.php
FIND

Code: Select all

$template->pparse('body');
BEFORE, ADD

Code: Select all

// shoutcast Panel - START
// MOD Ramon Fincken, Phpbbinstallers.com
include_once($phpbb_root_path . 'shoutcastparser.'.$phpEx);
	     	$template->assign_block_vars('chield', array(   
	     	"SHOUTCAST_PHPBB_OUTPUT" => $shoutcast_phpbb_output));  
// MOD Ramon Fincken

// shoutcast - END
OPEN

Code: Select all

templates/[yourtemplatename]/index_body.tpl
ADD

Code: Select all

<table width="100%" border="0" cellpadding="0" cellspacing="0" class="forumline"><tr><td>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="catHead" colspan="2" height="28"><span class="cattitle">Radio</span></td>
</tr>
<tr><td class="row1" align="left"><p class="genmed">

<!-- BEGIN shoutcastparser -->
{shoutcastparser.SHOUTCAST_PHPBB_OUTPUT}
<!-- END shoutcastparser --> 

<br /><br /></p></td></tr>
</table>


</td></tr></table>

DIY INSTRUCTIONS

Code: Select all

#edit
#// parameters for your SHOUTcast server - ** YOU WILL NEED TO CHANGE THESE **
#$shoutcast_host = 'rgtunez.co.uk';  // SHOUTcast station url
#$shoutcast_port = '8002';      // SHOUTcast station port number
#$shoutcast_password = '';  // SHOUTcast password
#$shoutcast_url = "http://" . $shoutcast_host . ':' . $shoutcast_port . "/listen.pls";
#// end of parameters for your SHOUTcast server



This looks like the one i need matey!!!

Does this cover an option of media player like Window media player, Real Player, Winamp to play the steams in?

Posted: Tue May 09, 2006 9:18 pm
by Daz wilde
Right ive done everything and got details off a site of which is streaming at the mo to link in with but mine doesnt work????

It doesnt even say radio offline????

Posted: Tue May 09, 2006 10:06 pm
by UseLess

Posted: Tue May 09, 2006 10:09 pm
by Daz wilde
UseLess wrote: Greetings,

Try this: http://www.custombuiltsoftware.co.uk/do ... status.zip


Have you got a demo of this mate??? or screen shots

Posted: Tue May 09, 2006 10:15 pm
by UseLess
Greetings,

http://forum.custombuiltsoftware.co.uk

however the radio is not on... but you'll get the idea...

Posted: Tue May 09, 2006 10:26 pm
by Daz wilde
UseLess wrote: Greetings,

http://forum.custombuiltsoftware.co.uk

however the radio is not on... but you'll get the idea...


Ooooooo i like that!!!!! Ill have a go now!!! Be back soon!!!

Posted: Tue May 09, 2006 10:36 pm
by Daz wilde
it says at the top of ile add {RADIO_STATUS} in index_body.tpl

Where abouts at the top does this go??

Posted: Tue May 09, 2006 11:30 pm
by UseLess
Greetings,

The top of the file will be line 1 if that line is occupied then move that line down one and make the 'radio_status' bit line 1...

Posted: Wed May 10, 2006 8:12 am
by Daz wilde
When i put it at the top, line 1 nothing shows after it??????????

Any clues