TinyPortal
Development => Block Codes => Topic started by: KingKoz on February 26, 2007, 06:48:44 AM
I was searching for a block that would give me a block that had a configurable list of stations and one that wasn't page dependent. Meaning I wanted to select a station to listen to and continue to surf while listening. I tried many of the existing blocks but none seemed to work with mp3s and my shoutcast station. So, I took one that was close to what I wanted and tweaked it til it worked for me. Here is what I came up with. It works with .pls, .rm and .aspx streams. It may work with others, I only tried those 3.
Enjoy
Koz
In your TP Block manager, just create a SCRIPTBLOCK and paste this code.
<SCRIPT type=text/javascript>
<!-- Original: Dick James (dick.james@blasiussolutions.net.co.nr) -->
<!-- Produced by Blasius Solutions. http://blasiussolutions.net.co.nr -->
<!-- Web Site: http://blasiussolutions.net.co.nr -->
<!-- Modified: KingKoz 2/2007 -->
<!-- Web Site: http://www.kozradio.biz -->
<!-- hide
function radioHome(url)
{
if(url==""){
alert("Please select station first.");
}
else{
spliturl = url.split("/");
window.open("http://"+spliturl[2]);
}
}
function nothing(){
// prevents errors when clicking on a blank link in IE.
}
// end -->
</SCRIPT>
<table align="center" border="1" cellspacing="2" cellpadding="0" bordercolor="black" bgcolor="silver" style="border: solid;">
<tr>
<FORM name=radio>
<tr>
<td align="center" valign="middle">
<select name="list" size="1" class="inputbox" onChange="window.location=this.value;">
<!-- change the lines below to the stations you want to listen to -->
<OPTION value="" selected>Select Radio Station...</option>
<OPTION value="">Classic Rock</option>
<OPTION value=http://live.kozradio.biz:5252/listen.pls>...KozRadio 5252</option>
<OPTION value=http://asx.abacast.com/wtkw-wkrl-32.asx>...TK 99 Syr, NY</option>
<OPTION value="">Jazz/News</option>
<OPTION value=http://asds9.syr.edu/ramgen/broadcast/waer.rm>...WAER SU</option>
<OPTION value="">Talk</option>
<OPTION value=http://www.bbc.co.uk/radio2/realmedia/fmg2.ram>...BBC Radio</option>
<OPTION value=http://www.bbc.co.uk/radio3/ram/r3g2.ram>...BBC Radio 2</option>
</SELECT>
</td>
</tr>
<tr>
<td align="center" valign="middle"><a name="radiolink" id="radiolink" href="javascript:nothing();" onClick="radioHome(list.value)"><font color="navy">Station Homepage</font></a>
</td>
</tr>
<tr>
<td align="center" valign="middle"><A href="http://www.winamp.com/" target=_new>WinAmp </A>or <a href="http://www.real.com">RealPlayer</a> required to use</font> </td>
</FORM>
</tr>
</table>
Just tried it seems to work well.Thanks
One ? how do you add more channels?
If you scroll down in the code the the section where the <FORM> elements are you will see a notation I made in the code showing where/how to chage the stations to the ones you want. One other note; you will notice there are <OPTION> lines that do nothing but act as header info for the station list. Those should be changed or deleted to suite your needs. You will need to know the URLs for the stations you want to listen to.
<!-- change the lines below to the stations you want to listen to -->
<OPTION value="" selected>Select Radio Station...</option>
<OPTION value="">Classic Rock</option>
<OPTION value=http://live.kozradio.biz:5252/listen.pls>...KozRadio 5252</option>
<OPTION value=http://asx.abacast.com/wtkw-wkrl-32.asx>...TK 99 Syr, NY</option>
<OPTION value="">Jazz/News</option>
<OPTION value=http://asds9.syr.edu/ramgen/broadcast/waer.rm>...WAER SU</option>
<OPTION value="">Talk</option>
<OPTION value=http://www.bbc.co.uk/radio2/realmedia/fmg2.ram>...BBC Radio</option>
<OPTION value=http://www.bbc.co.uk/radio3/ram/r3g2.ram>...BBC Radio 2</option>
Koz
Demo?
nice idea.. only problem is it requires one of two players i dont use :/
Ah, I think this rocks :D :up:
But, only two default radio stations worked: KozRadio and BBC 2 (which actually was Radio 3, not Radio 2)...???
And the Station Homepage didn't work either - nothing happens when clicking on it...
Never the less, I made a simple translation of the script into Swedish (below) :).
Mmmm, would be great to also have some info about what is being played on the station one chooses... Just like the KozRadio block on your own forum (http://www.esmclassof75.com/forum/), but a dynamic one that changes depending on what station the user chooses...
<SCRIPT type=text/javascript>
<!-- Original: Dick James (dick.james@blasiussolutions.net.co.nr) -->
<!-- Produced by Blasius Solutions. http://blasiussolutions.net.co.nr -->
<!-- Web Site: http://blasiussolutions.net.co.nr -->
<!-- Modified: KingKoz 2/2007 -->
<!-- Web Site: http://www.kozradio.biz -->
<!-- hide
function radioHome(url)
{
if(url==""){
alert("V g välj radiostation först.");
}
else{
spliturl = url.split("/");
window.open("http://"+spliturl[2]);
}
}
function nothing(){
// prevents errors when clicking on a blank link in IE.
}
// end -->
</SCRIPT>
<table align="center" border="1" cellspacing="2" cellpadding="0" bordercolor="black" bgcolor="silver" style="border: solid;">
<tr>
<FORM name=radio>
<tr>
<td align="center" valign="middle">
<select name="list" size="1" class="inputbox" onChange="window.location=this.value;">
<!-- change the lines below to the stations you want to listen to -->
<OPTION value="" selected>Välj radiostation...</option>
<OPTION value="">Blandat:</option>
<OPTION value=http://www.bbc.co.uk/radio3/ram/r3g2.ram>...BBC Radio 3</option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_p1.rm>...SR P1</option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_p2.rm>...SR P2</option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_p3.rm>...SR P3</option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_radiosporten.rm>...SR P4+Sport</option>
<OPTION value="">Blandad Musik:</option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_srbubbel.rm >...SR Bubbel </option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_metropol.rm >...SR Metropol </option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_p3star.rm >...SR P3 Star </option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_p3svea.rm >...SR P3 Svea </option>
<OPTION value="">Allmän Rock:</option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_p3rockster.rm>...SR P3 Rockster</option>
<OPTION value="">Klassisk Rock:</option>
<OPTION value=http://live.kozradio.biz:5252/listen.pls>...KozRadio 5252</option>
<OPTION value="">Klassisk Musik:</option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_srklassiskt.rm>...SR Klassiskt</option>
<OPTION value="">Kultur o samhälle:</option>
<OPTION value=rtsp://sr-rm.qbrick.com/broadcast/cluster/encoder/02038_srvarlden.rm>...SR Världen</option>
<OPTION value="">Lokala kanaler:</option>
<OPTION value=mms://sr-wm.qbrick.com/02038_SR-Jonkoping-High>...Radio Jönköping</option>
<OPTION value=mms://sr-wm.qbrick.com/02038_SR-Skaraborg-High>...Radio Skaraborg</option>
<OPTION value=mms://sr-wm.qbrick.com/02038_SR-Sormland-High>...Radio Sörmanland</option>
<OPTION value=mms://sr-wm.qbrick.com/02038_SR-Vastmanland-High>...Radio Västmanland</option>
</SELECT>
</td>
</tr>
<tr>
<td align="center" valign="middle"><a name="radiolink" id="radiolink" href="javascript:nothing();" onClick="radioHome(list.value)"><font color="navy">Stationens webbplats</font></a>
</td>
</tr>
<tr>
<td align="center" valign="middle"><A href="http://www.winamp.com/" target=_blank>WinAmp </A>eller <a href="http://www.real.com" target=_blank>RealPlayer</a> kan krävas.</font> </td>
</FORM>
</tr>
</table>
EDIT: I have now added quite a few radio statíons of interest - especially for Swedish users - in the code above...