WebRadio version 0.4 - free to share! 8)
I'm not very good in scripting, actually very poor. This is a blend of php and javascript and even a cookie. To all code-freaks: it's a mess, but I managed to get it working :-) Feel free to clean it up...
Features:
- offer streaming radio to your members
- station and volume are 'remembered' when browsing or switching channels
- no ugly windows mediaplayer :-)
- player status dynamically shown
Installation Instructions:
Just 3 steps!
Step 1) Choose Radio Stations
- find Interesting Radio Stations, for example here http://www.mikesradioworld.com/
- copy the links to the streaming-audio to WebRadio.htm (In the form. there are 5 of them in there already, you might want to replace them :-)
- add &station=RadioName right after the link-to-the-streaming-audio
(see the 5 examples already in WebRadio.htm, replace RadioName with the name of the station)
That was the hard part, now the easy bits ;) :
Step 2) Upload files
- create a folder called WebRadio in (the root) of your SMF folder
- upload WebRadio.htm + volup.jpg + voldown +jpg to that folder
Step 3) Create TinyPortal Block
- Add a left- or right PHP-Block (bar must be approx 230 pixels wide)
- Replace in the block-code.txt-file www.YOURSITE.com with your webaddress.
- Copy the content of block-code.txt in the block. (set also: Do not use title/frame)
That's all, enjoy :-)
Very cool :up:
very nice !
Cool :up: Dank je
This is pretty cool snippet, I have been tweaking with mine. I got some stations I want and it works great.
Is there anyway you can change the width for this? It doesnt seem to fit in a block that well.
I did not use the title/frame option but its still much bigger then the other ones.
Is there a way?
Thanks
Got it, autosize=true.
:)
Quote from: Greenbug on September 03, 2006, 11:13:55 PM
This is pretty cool snippet, I have been tweaking with mine. I got some stations I want and it works great.
Is there anyway you can change the width for this? It doesnt seem to fit in a block that well.
I did not use the title/frame option but its still much bigger then the other ones.
Is there a way?
Thanks
Got it, autosize=true.
:)
Where did you put this : autosize=true?
I have actually change mine around quite a bit, I drop the picture and changed the background (my forum isnt even close to yellow) and I also put the radio buttons all to the left.
This is the block code
if (isset($_COOKIE["WebRadio"]))
echo '<iframe id="radio" src="http://www.YOURSITE.com/WebRadio/WebRadio.htm' . $_COOKIE["WebRadio"] . '" width=165 height=200 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no FRAMEBORDER=0px><body style="border:none"></iframe>
<layer visibility=hide>
</layer>';
else
echo '<iframe id="radio" src="http://www.YOURSITE.com/WebRadio/WebRadio.htm" width=165 height=200 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no FRAMEBORDER=0px><body style="border:none"></iframe>
<layer visibility=hide>
</layer>';
The autosize=true is in the WebRadio.htm file
This is mine attached.
www.chicohotornot.com
I also like the fact that you can move around inside the forum and it picks right back where it was. very cool!
Update: The attached is error free.
Another thing that has made this very easy to edit is an open source free editor called TSWeditor - AWESOME!
http://tswebeditor.net.tc/
Thanks for sharin'.
I stopped it because it generates a lot of warnings / errors, about 300 pages in 10 minutes, lol.
I see on your page that it generates errors too, because I have this warning triangle in my explorer window saying :"Page build with errors".
If you put this string in the top of the code, the errors will stop filling your error log.
global $scripturl;
I'm sorry, most of the errors come from the calendar module I'm testing this also.
What remains is a script error.
I resized the webradio image to 155x140 pixels.
You can see it on one of my sites : http://www.badmuts.nu
This is the code I have in webradio.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META http-equiv=Cache-Control content=no-cache>
<META http-equiv=Pragma content=no-cache>
<META http-equiv=Expires content=0>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<script type="text/javascript">
<!--
var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++) { eq = nv[i].indexOf('=');
url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1)); }
q2 = url.q1;
station2 = url.station;
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
function querystring(name) {
// returns a named value from the querystring
var tmp = ( location.search.substring(1) );
var i = tmp.toUpperCase().indexOf(name.toUpperCase()+"=");
if ( i >= 0 ) {
tmp = tmp.substring( name.length+i+1 );
i = tmp.indexOf("&");
return unescape( tmp = tmp.substring( 0, (i>=0) ? i : tmp.length ));
}
return("");
}
function getLastVolume() {
// get the last used volume from url querystring
var lastVol = querystring("vol");
// if the volume exists, apply the volume to the player
if (lastVol!='') {
document.getElementById("MediaPlayer").settings.Volume = parseInt(lastVol);
}
}
function passVolume(what) {
// get the current volume
vol = document.getElementById("MediaPlayer").settings.Volume;
// add volume to the link
what.href += '?vol=' + vol;
}
function go(loc) {
//create cookie
vol = document.getElementById("MediaPlayer").settings.Volume;
adresje = '?q1=' + loc +'&vol=' + vol;
createCookie('WebRadio',adresje ,7);
var fileName =
location.pathname.substring(location.pathname.lastIndexOf('/')+1);
window.location.href = fileName + '?q1=' + loc + '&vol=' + vol;
}
function downVol(MediaPlayer) {
// get the current volume
MediaPlayer.settings.volume = MediaPlayer.settings.volume -20
//create cookie
vol = document.getElementById("MediaPlayer").settings.Volume;
adresje = '?q1=' + q2 + '&station=' + station2 +'&vol=' + vol;
createCookie('WebRadio',adresje ,7);
}
function upVol(MediaPlayer) {
// get the current volume
MediaPlayer.settings.volume = MediaPlayer.settings.volume +20
//create cookie
vol = document.getElementById("MediaPlayer").settings.Volume;
adresje = '?q1=' + q2 + '&station=' + station2 +'&vol=' + vol;
createCookie('WebRadio',adresje ,7);
}
//-->
</script>
<BODY bgColor=#FFFFCC leftMargin=0 topMargin=0 onload="getLastVolume()">
<SCRIPT LANGUAGE = "JScript" FOR = MediaPlayer EVENT = PlayStateChange(NewState)>
// Test for the current state.
// If playing, display the name of the current media.
switch (NewState){
case 1:
divState.innerHTML = "Playstate: Stopped";
// Toggle the button states.
btnPause.disabled = true;
btnPause.value = " Pause ";
btnStop.disabled = true;
break;
case 2:
divState.innerHTML = "Playstate: Paused";
break;
case 3:
divState.innerHTML = "Playstate: Playing";
divName.innerHTML = "Media name: " + Player.currentMedia.name;
// Toggle the button states.
btnPause.disabled = false;
btnStop.disabled = false;
break;
case 6:
divState.innerHTML = "Playstate: Buffering";
break;
case 7:
divState.innerHTML = "Playstate: Waiting";
break;
case 8:
divState.innerHTML = "Playstate: Media Ended";
break;
case 9:
divState.innerHTML = "Playstate: Transitioning";
break;
case 10:
divState.innerHTML = "Playstate: Ready";
break;
// Other cases go here.
default:
divState.innerHTML = "Playstate: Other";
}
</SCRIPT>
<table width="100%" border="0">
<tr>
<td>
<div align="left"><img src="WebRadios.jpg" width="155" height="140" align="middle"></div>
</td>
</tr>
</table>
<SCRIPT LANGUAGE = "JScript" FOR = MediaPlayer EVENT = StatusChange()>
// Display status. This requires Windows Media Player 9 Series or later.
divState.innerHTML = MediaPlayer.status;
</SCRIPT>
<SCRIPT>
var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++) { eq = nv[i].indexOf('=');
url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1)); }
station2 = url.station;
if (station2 === undefined) {document.writeln('<div align=center><font size=1 face=Verdana>choose your station:</font></div>')}
else {document.writeln('<div align=center><font size=1 face=Verdana>Now playing: <b>' + station2 + '</b></font></div>')}
checkPlayState(false);
//set cookie for sure
adresje = '?' + qs;
createCookie('WebRadio',adresje ,7);
</script>
<div id="divState" align="center" style=font-family:verdana;font-size:9px;color:#555555;></div>
<form name="qform" onSubmit=" return ProcessForm();">
<div align="center"><input type="radio" name="q1" onClick="go('http://www.omroep.nl/radio1/live64.asx&station=Radio 1');">
<font size=1 face="Verdana">Radio 1</font>
<input type="radio" name="q1" onClick="go('http://www.omroep.nl/radio2/live64.asx&station=Radio 2');">
<font size=1 face="Verdana">Radio 2</font><br>
<input type="radio" name="q1" onClick="go('http://ms.stream.garnierprojects.com/radio538&station=Radio 538');">
<font size=1 face="Verdana">538</font>
<input type="radio" name="q1" onClick="go('http://ms.stream.garnierprojects.com/kinkfm&station=Kink fm');">
<font size=1 face="Verdana">Kink fm</font><br>
<input type="radio" name="q1" onClick="go('http://www.garnierstreamingmedia.com/asx/skyradio.asp&station=Sky Radio');">
<font size=1 face="Verdana">Sky Radio</font>
<input type="radio" name="q1" onClick="go('');">
<font size=1 face="Verdana" color="red">off</font><br>
<br>
<img src="voldown.jpg" border="0" NAME="VolDown" VALUE="-vol" onmouseover='style.cursor="hand"' OnClick="downVol(MediaPlayer)">
<font size=1 face="Verdana"> volume </font><br>
<img src="volup.jpg" border="0" NAME="VolUp" VALUE="-vol" onmouseover='style.cursor="hand"' OnClick="upVol(MediaPlayer)">
</div>
</form>
<SCRIPT>
var WMP7;var d=document;var z;var link;
if(1){ //parent.canDetectPlugins() || parent.detectWindowsMedia()){
try {
if ((navigator.appName != "Netscape")) WMP7=new ActiveXObject('WMPlayer.OCX');
else if(window.GeckoActiveXObject) WMP7=1;
}
catch(e){WMP7=0;}
var qs = location.search.substring(1);
var nv = qs.split('&');
var url = new Object();
for(i = 0; i < nv.length; i++) { eq = nv[i].indexOf('=');
url[nv[i].substring(0,eq).toLowerCase()] = unescape(nv[i].substring(eq + 1)); }
if (vol='undefined') {vol = url.vol} else {vol=50}
link=url.q1;
z=parent.zender;
if(WMP7){
d.writeln('<OBJECT ID="MediaPlayer" width=155 height=64 classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" ');
d.writeln('standby="" type="application/x-oleobject">');
d.writeln('<PARAM NAME="URL" VALUE="'+link+'"><param name="volume" value="'+vol+'"><PARAM NAME="InvokeURLs" VALUE="false">');
d.writeln('<PARAM NAME="TransparentAtStart" Value="true"><PARAM NAME="AutoStart" Value="true"><PARAM NAME="AnimationatStart" Value="false"><PARAM NAME="ShowControls" Value="0"><PARAM NAME="autoSize" Value="false"><PARAM NAME="displaySize" Value="0">');
d.writeln('<PARAM name="uiMode" value="invisible">');
d.writeln('<EMBED type="application/x-mplayer2" ');
d.writeln('SRC="'+link+'" name="MediaPlayer" width="155" height="64" ShowStatusbar="0" AutoStart="1" InvokeURLs="0">');
d.writeln('</EMBED></OBJECT>');
}
else{
d.write('<OBJECT ID="MediaPlayer" CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" ');
d.write('standby="" TYPE="application/x-oleobject" width="155" height="64">');
d.write('<PARAM NAME="FileName" VALUE="'+link+'"><param name="volume" value="'+vol+'"><PARAM NAME="InvokeURLs" VALUE="false">');
d.writeln('<PARAM NAME="TransparentAtStart" Value="true"><PARAM NAME="AutoStart" Value="true"><PARAM NAME="AnimationatStart" Value="false"><PARAM NAME="ShowControls" Value="0"><PARAM NAME="autoSize" Value="false"><PARAM NAME="displaySize" Value="0">');
d.write('<PARAM NAME="ShowStatusBar" VALUE="false">');
d.write('<EMBED type="application/x-mplayer2" ');
d.write('src="'+link+'" Name="MediaPlayer" ShowStatusBar="1" width="155" height="64" AutoStart="1" InvokeURLs="0">');
d.write('</EMBED></OBJECT>');
}
}
else d.writeln('<font style="color:red;font-size:12pt;">U heeft geen MediaPlayer plugin!</font><a style="text-decoration:none;" href="http://www.op.tv/video_players.htm" target="_parent"><font style="color:green;font-size:12pt;"> Installeren?</font></a>');
</SCRIPT>
<script>
var stateg=document.getElementById("MediaPlayer");
//alert(stateg.PlayState);
</script>
</BODY></HTML>
And this is the block code :
global $scripturl;
if (isset($_COOKIE["WebRadio"]))
echo '<iframe id="radio" src="http://www.alohaspirit-nl.nl02.members.pcextreme.nl/badmuts/WebRadio/WebRadio.htm' . $_COOKIE["WebRadio"] . '" width=162 height=320 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no FRAMEBORDER=0px><body style="border:none"></iframe>
<layer visibility=hide>
</layer>';
else
echo '<iframe id="radio" src="http://www.alohaspirit-nl.nl02.members.pcextreme.nl/badmuts/WebRadio/WebRadio.htm" width=162 height=320 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no FRAMEBORDER=0px><body style="border:none"></iframe>
<layer visibility=hide>
</layer>';
Prolly it's something with the dimensions that I got wrong.
Yes it does error, but not in SMF/TP. I cleared my log and ran it a few times, reloading page etc.. no errors. Only in browser.
This is the error in IE attached, and the line 126 is divName.innerHTML = "Media name: " + Player.currentMedia.name;
This is line 125 and it works, can I put something after the "media name: " What would work for that?
divState.innerHTML = "Playstate: Playing";
Not sure how to fix it.
I am getting a DivName error in IE I believe its trying to get the song name but there is no place to display it. my guess.
I dont know that much about coding to fix it either. The Editor said it has many incorrect statemtents. All I did was take the image and add stations.
Works for me, but I'm easy
GB
Hahaha, since I've been to Kau'i, I've this 'hang loose' thing.
Nevertheless, this is like solving a puzzle.
I changed the image to transparant gif, changed the background to match my theme and made all the width values '99%'.
I outcommented the divName but still 2 script errors left.
Regel:183
Teken:1
Code:0
Fout:Object wordt verwacht (object expected)
URL:http://www.alohaspirit-nl.nl02.members.pcextreme.nl/
badmuts/WebRadio/WebRadio.htm?q1=
http://ms.stream.garnierprojects.com/kinkfm&station=Kink fm&vol=50
2)
Regel:129
Teken:1
Code:0
Fout:'btnPause' is niet gedefinieerd
URL:http://www.alohaspirit-nl.nl02.members.pcextreme.nl/badmuts/WebRadio/
WebRadio.htm?q1=http://ms.stream.garnierprojects.com/kinkfm&station=Kink fm&vol=50
I had to commented out these lines
114 // btnPause.disabled = true;
115 // btnPause.value = " Pause ";
116 // btnStop.disabled = true;
126 // divName.innerHTML = "Media name: " + Player.currentMedia.name;
129Ã, // btnPause.disabled = false;
130Ã, // btnStop.disabled = false;
177Ã, //checkPlayState(false);
in WebRadio.htm minus the image cut, and adding of stations.
Everything works as it should and no errors.
Again this is what it looks like now
www.chicohotornot.com
Looks nice on your site.
My nephew found missing ';' (semicolons?) two instances.
With the still outcommented divName, one error remains :
Regel:183
Teken:1
Code:0
Fout:Object wordt verwacht (error : object expected)
URL:http://www.alohaspirit-nl.nl02.members.pcextreme.nl/badmuts/WebRadio/WebRadio.htm?q1=http://cuestream.bydust.com/asx/5.asx&station=Q-music&vol=50
For today that's enough for me haha
I had that error, and if I am not mistaken I had to comment out lines 114, 115, & 116
I also tried using this editor which found the errors for me very quickly. You can go back and forth testing it before uploading it.
http://www.mpsoftware.dk/downloads.php
Cheers,
I would check the code above, since I had taken out the image altogether line number have changed.
Great man, thanks, I downloaded this editor, debugged and outcommented checkPlayState (false) and now mine is errorfree too
(http://www.badmuts.nu)
Thanks :up:
is the download in the original post the error free code ?
No this contains errors, you can outcomment the lines that Greenbug has posted here, then it's errorfree.
i like te image :D im gona use that only lol
Haha, I like the image too, I just had to make it a little smaller to fit in a left block
thanks
hmm followed Greenbug's edits as advised, can see the selectable stations etc plus the media player bar but nothing happens when click on anything.
could someone post complete working block and html code please.
I like your Radio very much, using it from Svaha. But the only problem was that it opens in the block, so everytime I switched pages it stopped. Now got it working in a popup. Just made a menuitem from it, linked it to /forum/WebRadio/WebRadio.htm and working ;) Make sure you set that the page have to open in a new page.
Good luck
anyone got a workin preview of this?
i see it works in IE but in FF nothing happens
Quote from: akulion on October 06, 2006, 02:51:38 PM
anyone got a workin preview of this?
i see it works in IE but in FF nothing happens
gona try out the radio mod from smf now"
http://mods.simplemachines.org/index.php?mod=422
'Mine' (http://www.badmuts.nu) doesn't work in firefox because the java console finds a script error:
Fout document.getElementById("MediaPlayer").settings has no properties
Bronbestand http://www.alohaspirit-nl.nl02.members.pcextreme.nl/badmuts/WebRadio/WebRadio.htm
Regel 78
it's this line in the html file : vol = document.getElementById("MediaPlayer").settings.Volume;
www.nzbpirates.nl/forum/WebRadio/WebRadio.htm
Works... Deleted the picture and added some text (Dutch)
thanks :up:
Quote from: Kiwitje on October 06, 2006, 05:46:59 PM
www.nzbpirates.nl/forum/WebRadio/WebRadio.htm
Works... Deleted the picture and added some text (Dutch)
I'm sorry, doesn't work (for me) in firefox and in ie I get a script error :
Regel:174
Teken:1
Code:0
Fout:Object wordt verwacht
URL:http://www.nzbpirates.nl/forum/WebRadio/WebRadio.htm
hmmmmmmm..... working here.....
I have a working radio at my site.But the problem is i was lookin for differnt stations to add how do i find the server information and directory information lets say at www.mikesradioworld.com or if anyone has suggestions on some where else to find stations. I spent the last couple hours trying to figure out how to get the info on my own with no luck.
Are there files or code for this that are working? hook me up.
I'm totally confused! I read the below msg and decided to check out the WebRadio block. What's confusingme is I can't seem to find the files/code to download. I must be missing something. I went into the block code snippet index, scrolled to the "W"'s and when I clicked the "WebRadio" link I am taken to the forum page (this one).
Can someone please provide a URL that points to the files so I can download and implement in my forum please?
Thanks,
Koz
Quote from: gijs on September 01, 2006, 04:10:00 PM
WebRadio version 0.4 - free to share! 8)
I'm not very good in scripting, actually very poor. This is a blend of php and javascript and even a cookie. To all code-freaks: it's a mess, but I managed to get it working :-) Feel free to clean it up...
Features:
- offer streaming radio to your members
- station and volume are 'remembered' when browsing or switching channels
- no ugly windows mediaplayer :-)
- player status dynamically shown
Installation Instructions:
Just 3 steps!
Step 1) Choose Radio Stations
- find Interesting Radio Stations, for example here http://www.mikesradioworld.com/
- copy the links to the streaming-audio to WebRadio.htm (In the form. there are 5 of them in there already, you might want to replace them :-)
- add &station=RadioName right after the link-to-the-streaming-audio
(see the 5 examples already in WebRadio.htm, replace RadioName with the name of the station)
That was the hard part, now the easy bits ;) :
Step 2) Upload files
- create a folder called WebRadio in (the root) of your SMF folder
- upload WebRadio.htm + volup.jpg + voldown +jpg to that folder
Step 3) Create TinyPortal Block
- Add a left- or right PHP-Block (bar must be approx 230 pixels wide)
- Replace in the block-code.txt-file www.YOURSITE.com with your webaddress.
- Copy the content of block-code.txt in the block. (set also: Do not use title/frame)
That's all, enjoy :-)