TinyPortal

Development => Block Codes => Topic started by: ontap on September 03, 2005, 04:20:17 PM

Title: Shoutcast Block
Post by: ontap on September 03, 2005, 04:20:17 PM
heres the code to have a shoutcast block if anyones intrested...


// SHOUTcast Block For Tinyportal
// Thanks To Max For Code

// Edit The Next Two Lines With Your SHOUTCAST Server Information
$host = "yourdomain.net";
$port = "80000";

//  Station Name
$streamtitle = "My Cool Radio"; //Your Station Name

// Stream Url
$streamurl = "http://$host:$port/listen.pls";

// Connect To SHOUTcast Server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
echo "<b>Cannot Connect To Shoutcast!</b>";
} else {

// Get Data From SHOUTcast Server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// Exit If Connection Is Broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(100000);
}

// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);

// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);

if ($status == "1") {
// To use any of the outputs below just uncomment (remove the double forward slashes) that line.
// Below is an example of all data available in the 7.html file made by the Shoutcast server
// **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE

echo "
<center>Playing On $streamtitle
<br>
<marquee>
<a href=\"$streamurl\">$song</a>
</marquee>
Birate @ $bit kbps <br> Listeners: $current / $max <br><center>
";
} else {
echo "
<b>$streamtitle Offline</b><br>Last Song Played Was:<br>
<marquee>$song</marquee>";
} }
Title: Re: Shoutcast Block
Post by: bloc on September 04, 2005, 08:48:36 AM
Thanks, ontap. :)
Title: Re: Shoutcast Block
Post by: mmeadwolfe on November 10, 2005, 01:59:02 PM
Nice little script there :D Is it possible to have the music play thoue?
Title: Re: Shoutcast Block
Post by: timtimtim on November 22, 2005, 09:13:57 PM
Has anyone managed to get this to work? I've set up my settings correctly but have been unable to do get it to function.
Title: Re: Shoutcast Block
Post by: ontap on November 22, 2005, 10:18:58 PM
$host = "yourdomain.net"; (http://yourshoutcastsite.com)
$port = "80000"; (Shoutcast Port)

these must be changed for the php block to work,
have you a link i can check?
Title: Re: Shoutcast Block
Post by: timtimtim on November 23, 2005, 12:30:07 AM
Host: 87.81.202.19
Port: 8000

I seem to be able to listen to it fine.

// SHOUTcast Block For Tinyportal
// Thanks To Max For Code

// Edit The Next Two Lines With Your SHOUTCAST Server Information
$host = "87.81.202.19";
$port = "8000";

//  Station Name
$streamtitle = "HyperNexus Radio"; //Your Station Name

// Stream Url
$streamurl = "http://$host:$port/listen.pls";

// Connect To SHOUTcast Server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
echo "<center><b>Cannot Connect To Shoutcast!</b><br />HyperNexus Radio is Offline</center>";
} else {

// Get Data From SHOUTcast Server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// Exit If Connection Is Broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(100000);
}

// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);

// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);

if ($status == "1") {
// To use any of the outputs below just uncomment (remove the double forward slashes) that line.
// Below is an example of all data available in the 7.html file made by the Shoutcast server
// **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE

echo "
<center>Playing On $streamtitle
<br>
<marquee>
<a href=\"$streamurl\">$song</a>
</marquee>
Birate @ $bit kbps <br> Listeners: $current / $max <br>
";
} else {
echo "
<b>$streamtitle Offline</b><br>Last Song Played Was:<br>
<marquee>$song</marquee>";
} }


www.hypernexusradio.co.uk (http://www.hypernexusradio.co.uk) Is the site of the radio, and
http://www.hypernexus.co.uk (http://www.hypernexus.co.uk) is my tinyportal address.
Title: Re: Shoutcast Block
Post by: ontap on November 23, 2005, 03:09:46 AM

The code works fine when i make a new php block,  :-\
you could try another way using SSI...

Open SSI.php
Find ?>

Before Add
// Shoutcast Block
function ssi_shoutcast()
{
global $sourcedir;

include_once("Shoutcast.php");
}


Copy "Shoutcast.php" to your forums directory,
Create A New php block and insert "ssi_shoutcast();"

[attachment deleted by admin]
Title: Re: Shoutcast Block
Post by: timtimtim on November 23, 2005, 03:38:30 AM
I'm afraid not - although it presents no parse errors, I still get the 'Cannot Connect To Shoutcast!' error in the block.
Title: Re: Shoutcast Block
Post by: timtimtim on December 03, 2005, 03:40:10 AM
Anyone using a working version of this that they wouldn't mind linking to?
Title: Re: Shoutcast Block
Post by: mmeadwolfe on December 03, 2005, 05:10:59 PM
I had a working example, but it was only for admins and i desided not to include it. Sorry. Thoue I just copyed the script exactly and changed the lines i was suposed to.

Quote from: ontap on September 03, 2005, 04:20:17 PM

$host = "yourdomain.net";
$port = "80000";
$streamtitle = "My Cool Radio"


Maby there are some settings on your server that are messed up, but don't take that as a fact, im just taking a random guess.

Try this:

Quote from: ontap on September 03, 2005, 04:20:17 PM

$host = "212.72.186.10";
$port = "8072";
$streamtitle = "1.FM"


Its a station i listen to often, and seems to work on my site.

Good Luck
Title: Re: Shoutcast Block
Post by: timtimtim on December 05, 2005, 04:59:09 PM
Wow - that's crazy. Now I put my settings in and try it again it works perfectly! Thanks for replying and giving me the desire to give it another shot :D
Title: Re: Shoutcast Block
Post by: pheadrus on June 19, 2006, 05:48:14 PM
This snippet is not working at my site. Although I have made the correct settings (From Winamp, I can listen the radio which settings are the same at the php-block) , It gives me error . I also tried for many radios.
What can be done  ???

Thnx...
Title: Re: Shoutcast Block
Post by: Max on June 19, 2006, 06:25:42 PM
Quote from: pheadrus on June 19, 2006, 05:48:14 PM
This snippet is not working at my site.

it should work when you put in the shoutcast server settings correctly.

what is your shourcast URL?
Title: Re: Shoutcast Block
Post by: erikman on June 19, 2006, 06:53:01 PM
 :D :D

Using on my site!
Fine script!
Title: Re: Shoutcast Block
Post by: pheadrus on June 20, 2006, 02:39:03 PM
Quote from: Maxâââ,¬Å¾Ã,¢ on June 19, 2006, 06:25:42 PM
it should work when you put in the shoutcast server settings correctly.

what is your shourcast URL?

Host: gunduzgece.no-ip.org
Port: 8000

These values are what I changed in your code. The exact url is that: http://gunduzgece.no-ip.org:8000/listen.pls (http://gunduzgece.no-ip.org:8000/listen.pls)

Here is my code in a php-block:

//SHOUTcast Block For Tinyportal
// Thanks To Max For Code

// Edit The Next Two Lines With Your SHOUTCAST Server Information
$host = "gunduzgece.no-ip.org";
$port = "8000";

//  Station Name
$streamtitle = "GündüzGece FM";

// Stream Url
$streamurl = "http://$host:$port/listen.pls";

// Connect To SHOUTcast Server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
echo "<b>GündüzGece yayında değil!</b>";
} else {

// Get Data From SHOUTcast Server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");

// Exit If Connection Is Broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(100000);
}

// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);

// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);

if ($status == "1") {
// To use any of the outputs below just uncomment (remove the double forward slashes) that line.
// Below is an example of all data available in the 7.html file made by the Shoutcast server
// **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE

echo "
<center>Ã...žu an Çalan: $streamtitle
<br>
<marquee>
<a href=\"$streamurl\">$song</a>
</marquee>
Bitrate @ $bit kbps <br> Dinleyici: $current / $max <br>
";
} else {
echo "
<b>$streamtitle Yayında değil</b><br>En son Çalan şarkı:<br>
<marquee>$song</marquee>";
} }
Title: Re: Shoutcast Block
Post by: Max on June 20, 2006, 03:05:40 PM
Quote from: pheadrus on June 20, 2006, 02:39:03 PM
The exact url is that: http://gunduzgece.no-ip.org:8000/listen.pls (http://gunduzgece.no-ip.org:8000/listen.pls)

link dont work.., maybe thats the cause of why its not working?
Title: Re: Shoutcast Block
Post by: pheadrus on June 24, 2006, 04:05:26 PM
Quote from: Maxâââ,¬Å¾Ã,¢ on June 20, 2006, 03:05:40 PM

link dont work.., maybe thats the cause of why its not working?

I have let my radio run on my computer (webserver on my computer).  I have tested many many times from office or other IP's. They can listen my radio, but on my forum, shoutcast will not display and says "not connected". When you tried maybe radio was off, because my radio was 2 days on-air (I like this term  :) ) after my question was here written by me.
Like my radio, any radio that I can listen can not be connected via my forum (my forum is NOT hosted on my computer).
This block will be a great modification for me, if I let it work  :)
Title: Re: Shoutcast Block
Post by: alan s on June 26, 2006, 10:15:09 PM
i dont believe it....................i've been looking for this script for months and then its here YES!!
Title: Re: Shoutcast Block
Post by: Thurnok on June 30, 2006, 05:43:00 AM
Quote from: pheadrus on June 24, 2006, 04:05:26 PM
I have let my radio run on my computer (webserver on my computer).  I have tested many many times from office or other IP's. They can listen my radio, but on my forum, shoutcast will not display and says "not connected". When you tried maybe radio was off, because my radio was 2 days on-air (I like this term  :) ) after my question was here written by me.
Like my radio, any radio that I can listen can not be connected via my forum (my forum is NOT hosted on my computer).
This block will be a great modification for me, if I let it work  :)

I have run a Shoutcast server for quite a long time.  There are a number of scripts out there for various CMS products that show Shoutcast info on your website.  What I have found however, is that not all Hosters allow the fsockopen() function which basically opens a socket from their server to allow you to connect to another server.  Because of this you might not be able to view Shoutcast info on your SMF site if it is hosted by a restrictive hoster.
Title: Re: Shoutcast Block
Post by: Muziek4um on August 09, 2006, 01:14:52 PM
Euh.... this is an old message but I came across the same problem. Check out mysite at the top of the right sidebar.

http://www.muziek4um.nl/forum/index.php
Title: Re: Shoutcast Block
Post by: Muziek4um on August 09, 2006, 01:18:14 PM
Correction!!!! It's already working!!! YEAH!!!

It was the site with the shoutcast that wasn't working :D

There's just one problem: the code changes the outlinement of the blocks under it.
Title: Re: Shoutcast Block
Post by: mpark on August 09, 2006, 10:43:32 PM
this block works awesome

timtimtim codes works fine but you have to change the server address:
http://www.tinyportal.net/smf/index.php?topic=701.msg12014#msg12014

thanks  :)
Title: Re: Shoutcast Block
Post by: Muziek4um on August 11, 2006, 08:25:17 PM
It works excellent for the stream but still changes the alignment of all the tables that come under it.

Check my board at de the right side bar.

http://www.muziek4um.nl/index.php

Everything should be outlined to the left.
Title: Re: Shoutcast Block
Post by: Muziek4um on August 11, 2006, 08:38:48 PM
But it's ok now.

It was just a matter of removing the center tag in de part of the script shown below:


// **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE

echo "
<center>Playing On $streamtitle
<br>
<marquee>
<a href=\"$streamurl\">$song</a>
</marquee>
Birate @ $bit kbps <br> Listeners: $current / $max <br>
";
} else {
echo "
<b>$streamtitle Offline</b><br>Last Song Played Was:<br>
<marquee>$song</marquee>";
} }
Title: Re: Shoutcast Block
Post by: WarBirD on October 31, 2006, 09:36:47 AM
Somehow possible to make it autorefresh ?
Title: Re: Shoutcast Block
Post by: akulion on October 31, 2006, 10:18:33 AM
auto refresh would require u to use an iframe with a "auto refresh" script which can be found on dynamicdrive.com
Title: Re: Shoutcast Block
Post by: WarBirD on October 31, 2006, 10:33:15 AM
Ok, found that, and that code (Javascript) from the auto-refresh i put in the same box where I put the code from the Shoutcast stuff above ?

Because the stuff above is a PHP script and this is Java Script, which means I canÂÃ,´t put them both in a PHP box, right ? Sry, i am not good with those things, thats why i ask.
Title: Re: Shoutcast Block
Post by: akulion on October 31, 2006, 10:37:06 AM
oh no if u did that then it would refresh your whole page

u will have to use Iframes for this

basically what u will have to do is create a new file called shoutcast.php or something and then call that into an iframe in the moddle of ur page

i havent seen this scrpt in detail - but im just giving some pointers - best to ask the author for full support :up:
Title: Re: Shoutcast Block
Post by: WarBirD on October 31, 2006, 10:50:07 AM
Ok, I did that, made a php file and uploaded it and then called it with IFRAME. Problem is, its displaying the contents of the Shoutbox query IFRAMEÂÃ,´d in the Box, not what it is supposed to do.  :laugh:
Title: Re: Shoutcast Block
Post by: WarBirD on October 31, 2006, 10:53:28 AM
Oh lol, never mind, works now.  ;) Thx.
Title: Re: Shoutcast Block
Post by: akulion on October 31, 2006, 10:54:00 AM
glad u got it sorted :D :up:
Title: Re: Shoutcast Block
Post by: WarBirD on October 31, 2006, 10:59:01 AM
Not without a little help i have to admit. ;) Thx again.
Title: Re: Shoutcast Block
Post by: Muziek4um on October 31, 2006, 12:38:32 PM
euh.. Ok :)
Title: Re: Shoutcast Block
Post by: whack on November 01, 2009, 12:32:40 AM
Hi would anyone know what line I would need to use if our radio shout has a password
admittedly I'm a bit of a noob at all this

but I would presume it just needs a line of code under the IP and port line with the password in it...and that's were I'm lost
Title: Re: Shoutcast Block
Post by: Zetan on November 01, 2009, 04:56:59 AM
Quote from: whack on November 01, 2009, 12:32:40 AM
Hi would anyone know what line I would need to use if our radio shout has a password
admittedly I'm a bit of a noob at all this

but I would presume it just needs a line of code under the IP and port line with the password in it...and that's were I'm lost

Hi Whack, you need a different player script. This one is for streaming from a 3rd party broadcaster, one which is not hosted by you.

You certainly don't want to be putting Usernames and Passwords in a block, you'd put those details in a separate file on your server which the code in the block calls for. The file is 1 of about 3 and will be a config script.

If you search for Shoutcast posts by me, I'm sure there are topics which I have posted in with player scripts. If not, I'll help you get it running a bit later... It's nearly 0500 here so I need to wake up..

I've also posted a stream status indicator script and a popup window script to put a player code into.


[edit] Try THIS (http://www.tinyportal.net/index.php?action=search2;params=YWR2YW5jZWR8J3wxfCJ8dXNlcnNwZWN8J3xaZXRhbnwifGJyZHwnfDEyLDI1LDExMCw3MCw2OSw1OSw2MCw5MSwxNSwxMDksMTI5LDE2Miw4OSwxNTQsNDYsMTMzLDIxNiwxMzAsODUsNjgsMTE4LDExOSwxMjAsMTMxLDE3NSw1Niw5NywxMTcsMTk3LDM2LDM1LDE5MSwxOTIsMTkzLDE5NCwxNzAsMTEzLDksMTUxLDg4LDMxLDExNSw2MywzMiwyNywyNiwyMywyMiwyMSwyMCwxOSwxOCwxNywyOSwxNTUsNzYsMTQ5LDE0NiwxMjIsMTA1LDg0LDgyLDEzNCwxNzEsMTc2LDE4MCwxNTYsMTUyLDEzNiwxMTQsMTA2LDkwLDgzLDgxLDgwLDc5LDc3LDc1LDczLDY1LDExNiwxNTgsMTU5LDE2MywxNjYsMTcyLDE3OCwxODMsMTg3LDE5OCwyMDUsMTU3LDEzOSwxMDgsNzgsNzQsMTY3LDE4OCwxOTUsMTI3LDEyOCwyMDEsMjEyLDMwLDgsNTEsMTIxLDU4LDE0Myw1MiwzMywyMDAsNTAsMTA3LDEyMywxMjQsMTM1LDEzNywxMzgsMTQ0LDE0NSwxNTAsMTUzLDE2MCwxNjEsMTY0LDE2OCwxNjksMTczLDE3NCwxNzcsMTc5LDE4MSwxODIsMTg0LDE4NiwxODksMTkwLDE5NiwxOTksMjAzLDIwNCwyMDYsMjEwLDIxMSwyMTMsMjE0LDIxNSw5OCw5OSwxNDAsMTQ4LDIwMiwxNDEsMTQyLDE0N3wifHNob3dfY29tcGxldGV8J3x8InxzdWJqZWN0X29ubHl8J3x8Inxzb3J0X2RpcnwnfGRlc2N8Inxzb3J0fCd8cmVsZXZhbmNlfCJ8c2VhcmNofCd8U2hvdXRjYXN0) Advanced Search I just did:

Advanced Search parameters:-
Search for: Shoutcast
User: Zetan

I haven't checked the results