web broadcasting

This forum is now closed as part of retiring phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
deejaybet
Registered User
Posts: 1814
Joined: Thu Dec 08, 2005 2:01 pm
Location: Derry, Northern Ireland
Contact:

Post by deejaybet »

pm me your config and shoutclass files
Organic Angel Alexiel
Registered User
Posts: 262
Joined: Tue Oct 24, 2006 10:30 pm
Location: Sunny Cal, USA
Contact:

Post by Organic Angel Alexiel »

I use simple shoutcast config. It gets the current song title (formatted to be 'exploded') the current and max listeners, and whether or not it is connected.

Code: Select all

	// MY SHOUTCAST MOD BeGIN
	
	// Fill in your own server information here:
	$port = "8000";
	$listenlink = "http://" . $board_config['server_name'] . ":" . $port . "/listen.pls"; //make link to stream
	
	$fp = fsockopen('127.0.0.1', $port, &$errno, &$errstr, 5); //open connection
	if(!$fp) {
		$success=2;
	}
	if ($success!=2) 
	{
		fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
		while(!feof($fp))
		{
			$page .= fgets($fp, 1000);
		}
		fclose($fp);
		$page = ereg_replace(".*<body>", "", $page);
		$page = ereg_replace("</body>.*", ",", $page);
		$numbers = explode(",",$page);
		$currentlisteners=$numbers[0];
		$connected=$numbers[1];
		
		if($connected==1)
			$wordconnected="yes";
		else
			$wordconnected="no";
		$peaklisteners=$numbers[2];
		$maxlisteners=$numbers[3];
		$reportedlisteners=$numbers[4];
	}

if($success!=2 && $connected==1)
	{

		// song information is splitted in artist - title:
		// This requires consistent artist & title format (no ' - ' in title/artist)
		// else you can use $numbers[6] as current song info below
		$song=explode(" - ",$numbers[6]);
		
		if ($song[0] == "" && $song[1] == "" && $song[2] == "")
		{
			$shoutcast = "is currently ONLINE<br>";
			$shoutcast .= "However, no songs are currently playing<br>";
			$shoutcast .= "Please check back later.<br>";
			$shoutcast .= ":::";

		}
		else
		{
			// strings can of course be replaced with your own bla
			$shoutcast = "";
			$shoutcast .= "<b>Artist:</b> " . $song[0] . "<br />";
			$shoutcast .= "<b>Title: </b>" . $song[1] . "<br />";
			$shoutcast .= "<b>Album: </b>" . $song[2] . "<br /><br />";
			$shoutcast .= "<b>[$currentlisteners/$maxlisteners users]</b><br />";
			$shoutcast .= "<b><a href='" . $listenlink . "'>Listen to " . $lang['Shoutcast'] . "</a></b><br />";
		}
	}
	else
	{
		$shoutcast = $shoutcast . "is currently OFFLINE.<br>";
		$shoutcast = $shoutcast . "Please check back later.<br>";
		$shoutcast = $shoutcast . ":::";
	}


	// MY SHOUTCAST MOD END
Need help with apache? Visit the Apache Lounge
I would heartily recommend reading through the Knowledge Base. I recently have and it has solved a number of questions I had.
EasyMod is great for a vanilla phpBB. Visit my website and see why I do everything by hand. :P
User avatar
rtrev64
Registered User
Posts: 286
Joined: Wed Nov 24, 2004 5:35 am
Contact:

Post by rtrev64 »

what do I config and wherre does this go?
Organic Angel Alexiel
Registered User
Posts: 262
Joined: Tue Oct 24, 2006 10:30 pm
Location: Sunny Cal, USA
Contact:

Post by Organic Angel Alexiel »

this is from my index.php if you only want it on your index page, then this is where it goes.

Code: Select all

   // Fill in your own server information here:
   $port = "8000";
   //change port to match yours
   $listenlink = "http://" . $board_config['server_name'] . ":" . $port . "/listen.pls";
    //change board_config['script_path'] to match your internet site link
   $fp = fsockopen('127.0.0.1', $port, &$errno, &$errstr, 5);
    // don't change 127.0.0.1 (or change to localhost) or change it to the IP 
    // address of the shoutcast server.
And just pass $shoutcast to the template:

Code: Select all

		'U_SHOUTCAST' => "http://" . $board_config['server_name'] . ":" . $port,
		'L_SHOUTCAST_TEXT' => $shoutcast,
You could put this into the page_header.php if you want it to appear anywhere in the site, not just on the index page.
Need help with apache? Visit the Apache Lounge
I would heartily recommend reading through the Knowledge Base. I recently have and it has solved a number of questions I had.
EasyMod is great for a vanilla phpBB. Visit my website and see why I do everything by hand. :P
User avatar
rtrev64
Registered User
Posts: 286
Joined: Wed Nov 24, 2004 5:35 am
Contact:

Post by rtrev64 »

This is from my index.php

//*********************************************
//** ShoutCast MOD - Begin Code Modification

// + Add
include($phpbb_root_path . 'includes/shoutcast_class.'.$phpEx);
$shoutcastPTC = new shoutcast;
$shoutcastPTC->set_host($sc_host);
$shoutcastPTC->set_port($sc_port);
$shoutcastPTC->set_passwd($sc_adminmpasswd);
// echo '<!-- ### SC MOD ### '; // Commnent error on fsockopen if can't connect.
$con_sc = $shoutcastPTC->get_status();
// echo ' ### SC MOD ### --> '; // Finish error!
$sc_status_arr = $shoutcastPTC->sc_stat;

if ( ($con_sc) && $sc_status_arr['stream_status'] ) {
$template->assign_block_vars('shoutcast_online', array(
'current_listeners_count' => $sc_status_arr['current_listeners_count'],
'average_listen_time' => $sc_status_arr['average_listen_time'],
'max_listeners' => $sc_status_arr['max_listeners'],
'shoutcast_url' => 'http://71.96.38.47:8001/' . $sc_host . ':' . $sc_port . '/',
'playing_song' => $sc_status_arr['playing_song']
));
$total_s_histoty = count($sc_status_arr['song_history_array']);
if ($songhistory_display > 0) { $template->assign_block_vars('shoutcast_online.show_song_history',array()); }
for ($ijkl = 0; ($ijkl < $total_s_histoty) && ($ijkl < $songhistory_display); $ijkl ++) {
$template->assign_block_vars('shoutcast_online.show_song_history.song_history', array(
'time' => date('g:i:s a',$sc_status_arr['song_history_array'][$ijkl]['date']),
'song' => $sc_status_arr['song_history_array'][$ijkl]['title']
));
}

} else {
$template->assign_block_vars('shoutcast_offline', array());
}


//** ShoutCast MOD - End Code Modification
//*********************************************

OAA I was looking at your code but i dont understand where it ngoes ion the index.php. erase that part and replace niot with the one code you given?
User avatar
rtrev64
Registered User
Posts: 286
Joined: Wed Nov 24, 2004 5:35 am
Contact:

Post by rtrev64 »

well it went from connection timed out 110 to success-(0)

but online radio station status is still "station offline"..
Organic Angel Alexiel
Registered User
Posts: 262
Joined: Tue Oct 24, 2006 10:30 pm
Location: Sunny Cal, USA
Contact:

Post by Organic Angel Alexiel »

all my code does is pulls its info from 7.html which is generated by the shoutcast server. By saying it is offline means that no source-client is connected to your shoutcast server. You need shoutcast dsp plugin for winamp to connect to the shoutcast server.

oh, updated version. Gives a bit more info:

Code: Select all

	// Fill in your own server information here:
	$port = "8005";
	$listenlink = "http://" . $board_config['server_name'] . ":" . $port . "/listen.pls"; 	
	$fp = fsockopen('127.0.0.1', $port, &$errno, &$errstr, 5);
	if(!$fp) {
		$success=2;
	}
	if ($success!=2) 
	{
		fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
		while(!feof($fp))
		{
			$page .= fgets($fp, 1000);
		}
		fclose($fp);
		$page = ereg_replace(".*<body>", "", $page);
		$page = ereg_replace("</body>.*", ",", $page);
		$numbers = explode(",",$page);
		$currentlisteners=$numbers[0];
		$connected=$numbers[1];
		
		if($connected==1)
			$wordconnected="yes";
		else
			$wordconnected="no";
		$peaklisteners=$numbers[2];
		$maxlisteners=$numbers[3];
		$reportedlisteners=$numbers[4];

		if($success!=2 && $connected==1)
		{
	
			// song information is splitted in artist - title:
			// This requires consistent artist & title format (no ' - ' in title/artist)
			// else you can use $numbers[6] as current song info below
			$song=explode(" - ",$numbers[6]);
			
			if ($song[0] == "" && $song[1] == "" && $song[2] == "")
			{
				$shoutcast = "is currently ONLINE<br>";
				$shoutcast .= "However, no songs are currently playing<br>";
				$shoutcast .= "Please check back later.<br>";
				$shoutcast .= ":::";
	
			}
			else
			{
				// strings can of course be replaced with your own bla
				$shoutcast = "";
				$shoutcast .= "<b>Artist:</b> " . $song[0] . "<br />";
				$shoutcast .= "<b>Title: </b>" . $song[1] . "<br />";
				$shoutcast .= "<b>Album: </b>" . $song[2] . "<br /><br />";
				$shoutcast .= "<b>[$currentlisteners/$maxlisteners users]</b><br />";
				$shoutcast .= "<b><a href='" . $listenlink . "'>Listen to " . $lang['Shoutcast'] . "</a></b><br />";
			}
		}
		else
		{
			$shoutcast = $shoutcast . "is currently OFFLINE.<br>";
			$shoutcast = $shoutcast . "Please check back later.<br>";
			$shoutcast = $shoutcast . ":::";
		}
	}
	else
	{
		$shoutcast = $shoutcast . "Shoutcast couldn't connect.<br>";
		$shoutcast = $shoutcast . "Please contact admin.<br>";
		$shoutcast = $shoutcast . ":::";
	}
$fp = fsockopen('127.0.0.1', $port, &$errno, &$errstr, 5);
url - or - IP Port error# errorStr timeout
tells php to connect to shoutcast on the specified port, and if no connection timeout after 5 seconds. If it doesn't connect properly, it gives you message that it couldn't. If it does connect it tells you if a source is connected. And if there is, it tells you what is playing.


and if you wanted to embed it into a website, so it connects and starts playing music:

Code: Select all

<object id="MediaPlayer1" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
								standby="Loading Microsoft Windows&reg; Media Player components..." type="application/x-oleobject"
								width="0" height="0" VIEWASTEXT>
								<param id="hFilename" name="fileName" value="http://www.example.com:8000/"></param>
								<param name="AnimationAtStart" value="true"/>
								<param name="AutoStart" value="true"/>
								<param name="ShowStatusBar" value="True">
								<param name="ShowStatusBar" value="false"/>
								<param name="transparentatStart" value="false"/>
								<param name="Autosize" value="true"/>
								<param name="showControls" value="true"/>

								<param name="Volume" value="-10"/>
								<embed id="hPlayer" stretchtofit="1" displaysize="1" autosize="1" height="0" autostart="1" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" showcontrols="1" volume="-10" src="http://www.example.com:8000/" width="0"></embed>
						  </object>
and that will work with video (just change the height and width)
Need help with apache? Visit the Apache Lounge
I would heartily recommend reading through the Knowledge Base. I recently have and it has solved a number of questions I had.
EasyMod is great for a vanilla phpBB. Visit my website and see why I do everything by hand. :P
User avatar
rtrev64
Registered User
Posts: 286
Joined: Wed Nov 24, 2004 5:35 am
Contact:

Post by rtrev64 »

Thanks again for your help OAA..

all my code does is pulls its info from 7.html which is generated by the shoutcast server. By saying it is offline means that no source-client is connected to your shoutcast server. You need shoutcast dsp plugin for winamp to connect to the shoutcast server.


I have the shoutcast dsp on and uploaded otherwise my radio would not be working? people are telling me it works, does it?

http://71.96.38.47:8001/

Is this code from the index.php?
User avatar
rtrev64
Registered User
Posts: 286
Joined: Wed Nov 24, 2004 5:35 am
Contact:

Post by rtrev64 »

bad mod yall....
Post Reply

Return to “[2.0.x] MOD Requests”