PHP SAM Cookie Rating Script

SAM Broadcaster is a fully featured internet broadcasting program that includes everything you need to start your own Internet Radio station. From automation, playlist management, encoders, statistics and web intergration. It is made by the folks at Spacial Audio Solutions and it is one of the center pieces of software that drives Celtic Radio.

The SAM Broadcasting package comes with a few different ways to publish your radio website. One is through a HTML template system and the other is through a PHP template system. Our article will focus on the latter (PHP) as that is what we have used at Celtic Radio and is the focus of our Cookie Rating Script!

Spacial Audio has done a great job creating the SAM broadcasting Internet Radio system. The included PHP template system using our favorite scripting language was a big selling feature for us! However, this system is just a default template and is not meant to be the theme of your broadcasting website. One feature we identified rather quickly was the ability for our listeners to rate the currently playing song.

Thus was born the idea for the PHP SAM Cookie Rating Script. The purpose of this script is to allow for a cookie based rating system that works in conjunction with the default PHP template. Listeners can rate a song once every 24 hours and only when that song is playing on your broadcast. Some broadcasters have chosen to only allow one rating per song, but we believe that giving our listeners the ability to rate a song multiple times over time will create a better broadcast by playing the songs listeners want to hear. Not only does this script provide a rating system, but it also adds weight to a song based on the following formula: 

Rating & Weight System
Rating of 5; add 5 to the weight. 
Rating of 4; add 3 to the weight.  
Rating of 2.5; add 0 to the weight.  
Rating of 1; add -3 to the weight. 
Rating of 0; add -5 to the weight.

Additionally, listeners will be able to see the current rating and weight of the song upon a successful rating via a pop-up web page. 

Because of buffering issues with web radio, sometimes the song playing will not match what shows on your website – it could be off by 5 seconds or 20 seconds. Therefore, we have built in a check that prevents rating a song that does not match what is currently playing on your broadcast.

Ok, enough with explanations, lets actually get into the working script. Open up your favorite PHP editor or development tool, our favorite is TextPad by Helios Software Solutions, and create a file named “ratesong.php”. Download the complete PHP Cookie Rating Script and follow the detailed instructions to install all necessary scripts, html and graphics.

To see a working example of the PHP Cookie Rating Script, visit Celtic Radio.

* Included with this script are the stars.gif graphic set to display rating stars on your website. Example:

* Please note that on we use a thumbnail version(100×100) to display a smaller version of the album cover in the rating script. You may need to adjust the pop-up size of the webpage to adjust to the standard size you use for displaying album covers.

* We have reports of this script not working for some people. The problem appears to be with the javascript code in the rating form. Make sure that the $songid variable is picking up the songid properly, otherwise the script will break. We use $song[‘songID’] to grab the song’s ID, but it is possible that the default SAM script uses a different variable array.

Any questions at all on installing this script, ways to make it better or just to say “Hello”, give me a shout at Celtic Radio.

Download: PHP Cookie Rating Script

About The Celtic Highlander

So, you might be wondering now how did Celtic Radio come to be? What is our inspiration? Celtic Radio was created to bring together a community of listeners, performers and musicians to share and converse in Celtic culture. Our inspiration for this endeavour is the music, but let’s face it, the radio waves and TV are ruled by an endless barrage of top 40 musicians and performers. Listen to your local AM or FM band and chances are you will not find many Celtic music stations, if you find any at all! How then can the devoted musicians that play at the Irish Festivals and Highland Games ever get heard beyond that venue? How can people discover Celtic music if there is no place to listen? Hence was born the idea of a free 24 hour Celtic Radio station available on the World Wide Web for all to enjoy.
This entry was posted in Internet Radio. Bookmark the permalink.

Leave a Reply