====== Play Radio UK, Radio Script for Second Life ======
[[http://www.secondlife.com|{{ :wiki:secondlife:insl_logo_75.gif|In Second Life}}]]
Need help? Contact StevenSDF Fisher in world or [[:contact]] on site.
Also see [[setting up a radio broadcast]] for creating your own station.
8-) If you're looking for something a little more fancy, I also have a version of this which uses a settings note card and play list note card, for that L$200 would be nice. That's good considering when I looked around before creating this script I could only find radios at around L$1,000. My price could be bartered though.8-)
Please note that Play Radio UK has gone into liquidation, it may return one day. However, because this script is for listening to their stations it could compromise the availability of this script.
===== What to do =====
* Create a new script in your inventory.
* Copy and paste the code.
* On land you own, build something to use as the radio.
* Copy the script from your inventory into the prim.
===== Use =====
* Once copied should start immediately.
==== Changing Station ====
* Click the radio prim
* Select the station from the blue drop down.
**Note:** if this doesn't work, make sure you own the land the radio is on, or at least have permission to alter the media stream of the land. Also make sure you click the play button on the viewer, just above the "map," or "Inventory" button.
===== The Script =====
/////////////////////////////////////////////////
// Copyright (c) 2008-2009 Steven Sulley (StevenSDF
// Fisher), all rights reserved.
// Free to copy, please credit me for this script
// Do not distribute as your own creation.
// Please don't alter this header comment.
//////////////////////////////////////////////////
// All Play Radio UK Stations and their logos and
// all are copyright (c) Play Radio UK, all rights
// reserved.
//////////////////////////////////////////////////
// http://www.playradiouk.com/
// http://www.sdf.me.uk/
//////////////////////////////////////////////////
//List of play radio channels
// The ip's are what will need updating if something breaks, you can find them all by
// searching on the shoutcast website and looking in the pls files.
list channels = ["", "http://audio1.playradiouk.com:8440", "http://audio1.playradiouk.com:9088",
"http://audio1.playradiouk.com:8070", "http://audio1.playradiouk.com:8320", "http://audio1.playradiouk.com:8210",
"http://audio1.playradiouk.com:8430", "http://audio1.playradiouk.com:8300", "http://audio1.playradiouk.com:8340",
"http://audio1.playradiouk.com:8360", "http://audio1.playradiouk.com:8040", "http://audio1.playradiouk.com:8490"];
// These are the names that show on the buttons.
list names = ["Off", "Play One UK", "Play Two UK",
"Play Classical", "Play Country", "Play Dance",
"Play Gold", "Play Jazz", "Play Love",
"Play Reggae", "Play Rock", "Play Talk"];
//player consts and vars
integer locked = FALSE; //Setting this to TRUE will mean only you can use this.
integer CHANNEL = 128;
string defaultPlayItem = "Play Two UK"; //Station name to start on
//=========== Nothing below should be changed ===========
//Consts and vars
integer MAX_BUTS_PER_PAGE = 9;
integer current = -1;
key lastTouch = NULL_KEY;
integer numPages;
integer curPage = 0;
//Functions
//Loads the selected music.
loadRadioStation(integer chan) {
llSay(0, "Loading " + llList2String(names, chan) + "...");
llSetParcelMusicURL(llList2String(channels, chan));
current = chan;
}
//Displays the next page of the menu (wraps).
pageNext() {
curPage++;
if (curPage > numPages)
curPage = 0;
showPage();
}
//Displays the previous page of the menu (wraps).
pagePrevious() {
curPage--;
if (curPage < 0)
curPage = numPages;
showPage();
}
//Creates the menu and displays it.
showPage() {
integer start = curPage * MAX_BUTS_PER_PAGE + curPage;
integer end = start + MAX_BUTS_PER_PAGE;
list options = llList2List(names, start, end);
options = llListInsertList(options, ["< Prev"], 0);
options = llListInsertList(options, ["Next >"], 2);
llDialog(lastTouch, "Currently Playing: "+ llList2String(names, current) +"\n\nPick a Station or Ignore:\n Page: " +
(string)(curPage + 1) + " of " + (string)(numPages + 1), options, CHANNEL);
}
default {
state_entry()
{
if (current == -1) {
llSay(0, "Loading default stream on start...");
integer choice = llListFindList(names, [defaultPlayItem]);
if (choice == -1) llSay(0, "Sorry that was an invalid option.");
else loadRadioStation(choice);
numPages = llGetListLength(names) / MAX_BUTS_PER_PAGE;
}
if (locked) llListen(CHANNEL, "", llGetOwner(), "");
else llListen(CHANNEL, "", NULL_KEY, "");
}
touch_start(integer total_number)
{
lastTouch = llDetectedKey(0);
curPage = 0;
showPage();
}
listen(integer channel, string name, key id, string message) {
integer choice = llListFindList(names, [message]);
if (choice == -1) {
if (message == "< Prev") pagePrevious();
else if (message == "Next >") pageNext();
else llSay(0, "Sorry that was an invalid option.");
}
else loadRadioStation(choice);
}
changed(integer mask) {
if (mask & CHANGED_OWNER) llResetScript();
}
}
===== Version History =====
* 1.4.2 - 2009-10-05
* FIXED: a problem in the paging code caused by separating the lite version from the commercial one.
* 1.4.1 - 2009-10-04
* FIXED: an unneeded function was left in causing compile problems.
* 1.4 - 2009-10-04
* Added pagination allowing for more than twelve stations to be listed.
* 1.3 - 2009-06-13
* Altered the station list to use host names.
* FIXME Allow pagination so more than twelve stations can be listed in the script.
* 1.2 - 2009-06-11
* Due to server changes all the IP Addresses needed changing.
* Added more Play Radio stations
* 1.1 - 2008-03-11
* Updated to accommodate Play Radio UK split into Play One UK and Play Two UK
* 1.0 - 2008-02-24
* Initial release