Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Mr.FixIT on February 05, 2013, 03:51:40 AM

Title: Radio for smf
Post by: Mr.FixIT on February 05, 2013, 03:51:40 AM
Updated Code...2.9.2013:
Add your own asx links and add name of the asx to option area.  This is final to me.  Hope everyone enjoys this addon.  Thanks goes out to mashby for advice.  Tested on my site which has smf 2.0.4 in portal block using firefox, ie9 and chrome.  Also worked on friends site which has Drupal so that was nice to know for gp.

<DIV align="center" style="color:#435BB3;"><P align=center>Radio</P></DIV>
<DIV align="center" style="color:#fff;">
<P align=center><SELECT onchange=PlayIt(this.value) name=player>
<OPTION value="#">= Select Channel =</OPTION>
<OPTION value="link here.asx">1. music1</OPTION>
<OPTION value="link here.asx">2. msuic2</OPTION>
<OPTION value="link here.asx">3. music3</OPTION>
</SELECT>&nbsp; <SPAN style="FONT-WEIGHT: bold"></SPAN></P></DIV>
<DIV id=music style="TEXT-ALIGN: center">
<P>
<OBJECT id=MediaPlayer2 codeBase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab# Version=5,1,52,701" type=application/x-oleobject height=200 standby="Loading Microsoft WindowsÃ,® Media Player components..." width=300 classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95>
<EMBED height="200" width="300" showstatusbar="1" url="" uimode="full" showcontrols="true" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" type="application/x-mplayer2" loop="False" autostart="True"></EMBED></OBJECT></P></DIV>
<DIV style="TEXT-ALIGN: center">&nbsp;</DIV>
<DIV style="TEXT-ALIGN: center"></DIV>
<P style="TEXT-ALIGN: center">
<SCRIPT type=text/javascript>
function PlayIt(what){
document.getElementById('music'). innerHTML='<object width="300" height="200" '
      +'classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '
      +'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" '
      +'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
      +'<param name="url" value="'+what+'">'
      +'<param name="uiMode" value="full">'
      +'<param name="autoStart" value="true">'
      +'<param name="loop" value="false">'
      +'<embed type="application/x-mplayer2" '
      +'pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" '
      +'showcontrols="true" uimode="full" width="300" height="200" '
      +'src="'+what+'" autostart="1" loop="False">'
+'</OBJECT>'; }
</SCRIPT>
</P>


Pic of my radio...
http://i45.tinypic.com/kdl4cx.jpg
Title: Re: Radio for smf
Post by: kat on February 05, 2013, 06:46:23 AM
I moved this to "Tip and tricks", coz the "Feature requests" board is for requesting features to be included in the next version of SMF.

Thanks for that, though! :)
Title: Re: Radio for smf
Post by: kat on February 05, 2013, 04:08:13 PM
Quote from: Mr.FixIT on February 05, 2013, 03:38:48 PM
Thank you for moving my post....sorry still getting use to your forum here. 

No sweat, mate. I've been here for eight hundred years and some of it still baffles me. ;)
Title: Re: Radio for smf
Post by: mashby on February 05, 2013, 10:42:03 PM
I like the concept for sure. As a portal block bit of code, there's a lot of unnecessary bits and pieces. The whole thing is wrapped in <center> which is deprecated. The <html> part, the <head> part, the <body> part all exist before you even put your code in the portal block. I'm imagining the code you supplied work, but it's rather non-standard in terms of a portal block. You should consider removing a lot of this before using on a portal block. I sure appreciate your efforts though! :)
Title: Re: Radio for smf
Post by: Mr.FixIT on February 08, 2013, 02:50:58 PM
Updated first post with updated code.  Thanks mashby for your advice.   ;)

Title: Re: Radio for smf
Post by: Realinfo on April 24, 2013, 01:04:53 AM
also tell some websites from where we can get streaming link
Title: Re: Radio for smf
Post by: prozacer on May 26, 2013, 11:48:39 PM
Finally, I found it! Thank a lot
Title: Re: Radio for smf
Post by: Black Tiger on December 14, 2015, 07:10:47 PM
Sorry to bump this thread, but I love this and thread and no radio mod was made yet. :-\
But luckily there is this code! :D

I only got 1 question. On Vbulletin I had a radio mod which kept on playing music, also when I was visiting other parts of the forum, so when switching to another thread of forum.

Today I implemented this code and it works fine as long as you stay on the same page. As soon as you open a thread the page gets reloaded and radio stops working. You have to select the station again.
I'm working with Simpleportal, maybe that has something to do with it.

Is there a way to fix this so the radio will keep on playing also when visiting other threads and forum sections?
Title: Re: Radio for smf
Post by: Jade Elizabeth on December 14, 2015, 08:46:39 PM
You could have it play stream in a new window, thats how modern stations do it.
Title: Re: Radio for smf
Post by: Black Tiger on December 15, 2015, 08:51:10 AM
Thank you Jade. However in that case the users should have their popup killers disabled. Would be nice though.
I only don't know how to write this so it will become a new window.
Title: Re: Radio for smf
Post by: Bigguy on December 15, 2015, 09:15:06 AM
I have an OLD radio mod from years ago. I have not tried it since torniyo left my site. Not sure if it could be updated or not. I can look into it I guess and see whats going on.
Title: Re: Radio for smf
Post by: Jade Elizabeth on December 15, 2015, 09:17:31 AM
You would only run into that if you're forcing the radio on viewers, which is wrong. You should have a link that opens the stream in a new window - no issue there.

Look at how this site does it:
http://www.fox.com.au/ (click listen now in the header)

Title: Re: Radio for smf
Post by: Black Tiger on December 15, 2015, 09:33:31 AM
I don't want to force it onto my users.
The fox.com.au site uses a complete new page withtout the old page present, so that's not what I want.
We've got a forum for posting and want the music on the background for visitors. So maybe a little small extra window would be nice as a solution when they have selected the station they want to listen to.
However, the vbulletin mod was just in the portal and no new window was necessary, that would be ideal.

This piece of code works the same, except for the radio being stopped by visiting another thread. Maybe that was fixed by a cookie or a session thing, I don't know. Over at Simpleportal I got some help which might have fixed it with implenting a cookie.

@Bigguy: Maybe you mean an old SMF 1.1. radio mod? In fact this current code is fine, I only need a solution so radio will keep playing when looking at other parts of the forum.
Title: Re: Radio for smf
Post by: Jade Elizabeth on December 16, 2015, 08:32:33 PM
Yes but you can make it say that it's a radio page for x site, and it will always be playing in the background, and you can have it auto load in the background too :). And it would be nice to customise it with your own stuff, you can have Slammeddimes recenttopics on it or something so it automatically updates a list of topics....that way if people close your site to listen they still see those topics and may come back :D.

I would assume for what you want though, you would need some sort of javascript or framesets....or perhaps an iframe or something.
Title: Re: Radio for smf
Post by: Black Tiger on December 16, 2015, 08:37:32 PM
I've read something about it, to have it play in a little separate windows, an iframe would be nice. But I want to put my own choice of radio stations in there. So this piece of code is good enough (except for Google Chrome which does not work since the npapi is disabled).

However, an iframe for this code would be nice. I'm just waiting for it.
Title: Re: Radio for smf
Post by: margarett on December 16, 2015, 08:40:31 PM
Quote from: Black Tiger on December 14, 2015, 07:10:47 PM
Today I implemented this code and it works fine as long as you stay on the same page. As soon as you open a thread the page gets reloaded and radio stops working. You have to select the station again.
There is just no good way to do it in SMF (and, AFAIK, also not directly in vB).

When SMF changes a page, a new page requests starts in index.php, which then performs all the why's and why-not's until you see the new page contents. That means that your browser, which has requested the radio when the last page loaded, will receive a new request and that will reset the "radio session".

For that to work, you need to load the player in your page (eg: index.html) and the forum needs to run inside an iframe or similar. That way the player is loaded with the "main page" while SMF is loaded in the iframe. When there is a page change in SMF only the iframe's content changes but the main page is still the same so the player keeps playing.

edit: ninja'd :P
Title: Re: Radio for smf
Post by: Black Tiger on December 16, 2015, 08:59:03 PM
I'm going to do it in a seperate window, it's the best way and easy to implement.;)
Title: Re: Radio for smf
Post by: Jade Elizabeth on December 16, 2015, 09:44:15 PM
See I'm not crazy, and you can make the best of a ******ty situation too by putting recent topics in there and making it branded and stuff :D.
Title: Re: Radio for smf
Post by: Black Tiger on December 16, 2015, 10:14:16 PM
I never said or thought you were crazy. It's a nice idea! ;)
Title: Re: Radio for smf
Post by: Jade Elizabeth on December 19, 2015, 09:52:40 PM
Ha ha I know, it's just something we Aussie's say when someone says no to our idea then later agrees with it. We're weird like that ha ha.

I wish I could offer a better solution but honestly it would slow you down and annoy people so I would avoid what you're trying to do. Also it would be a HUGE pain to maintain and operate so yeah.

I actually used to do internet radio and I had something on my forum to show on or off air buttons but the radio would load in Winamp. Also the service that allowed the on and off air buttons has since closed. It was a lot of fun.
Title: Re: Radio for smf
Post by: Black Tiger on December 20, 2015, 10:10:56 AM
I implemented my own idea like I really wanted it, with a link and a seperate little window that opens so my users can hear their favorite radio without the need of having the forums open.
Next to that, I implemented kind of your idea to create a page with a lot of radio, embedded in the forum's CMS.

I also got some great help from Chen Zen on Simpleportal who wrote a great piece of code in html5 which can be used via a pulldown and creates a seperate window from the pulldown too. I'm sure some peope here can use that to their benefit too.

A friend of mine still does internet radio which also gone via cable, and their station now even got a real "air" broadcast license.
They only thing I'm wondering is if the default black VLC screen (or mediaplayer screen when using IE) can be replace by some jpg of your own. Do you have any clue about that? Or isn't that possible?
At the moment we use that extra little separate window with a pull down selection for at the moment 4 different ration stations, so users can even change station via that option when listening.
Title: Re: Radio for smf
Post by: Jade Elizabeth on December 21, 2015, 10:08:13 PM
Nah we asked people to use Winamp for our radio. Good on you for getting it working :).