Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Radio Top2000_Radio_Stations_Player  

Top2000_Radio_Stations_Player

This is an automatically updating radio player with several thousand stations.
If your land is owned by a group, you will need to deed the prim to the group. Just edit the prim that the script is in, set 'Group:' to the same group as the land, and click 'Share with Group'. Then click the prim and select the Cartegory and radio station and enjoy free music!

Category: Radio
By : Ferd Frederix
Created: 2013-12-14 Edited: 2017-03-24
Worlds: Second Life

the Zip file

Download all files for Top2000_Radio_Stations_Player
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Remote parcel script.lsl
Get file # 2. Top_Radio_Stations_Player_1.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // More information on this radio player is at <a href="http://www.outworldz.com/Secondlife/posts/streaming">this link</a>
3 // Copyright 2010 Ferd Frederix
4 // License:
5 // Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
6 // http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US
7 // That means this must always be free.
8
9 // V1.1 allow longer names
10
11 integer mode ; // true if we are in refresh mode
12 list lCategories; // list of categories
13 list lStations; // list of stations
14 key http_request_id; // key of the current HTTP request
15 integer busy = 0; // go away, I'm budy
16
17 integer type; // 3 possible http transactions
18 string genre; // the category
19 string url; // the last URL
20 string station; // current station
21 integer menuChannel; // int of the channel number
22 key user; // the poerson who touched me
23 integer listen_id; // int of the current listener
24 string pubpriv = "Public";
25
26 // from the menu system http://wiki.secondlife.com/wiki/SimpleDialogMenuSystem
27 integer N_DIALOG_CHOICES;
28 integer MAX_DIALOG_CHOICES_PER_PG = 8; // if not offering back button, increase this to 9
29 string PREV_PG_DIALOG_PREFIX = "< Page ";
30 string NEXT_PG_DIALOG_PREFIX = "> Page ";
31 string DIALOG_DONE_BTN = "Done";
32 string DIALOG_BACK_BTN = "<< Back";
33
34 integer pageNum;
35 list DIALOG_CHOICES;
36
37 giveDialog(key ID, integer pageNum) {
38
39 list buttons;
40 integer firstChoice;
41 integer lastChoice;
42 integer prevPage;
43 integer nextPage;
44 string OnePage;
45
46 CancelListen();
47
48 menuChannel = llCeil(llFrand(1000000) + 11000000);
49 listen_id = llListen(menuChannel,"","","");
50 mode = FALSE;
52
53
54 N_DIALOG_CHOICES = llGetListLength(DIALOG_CHOICES);
55
56
57 if(N_DIALOG_CHOICES <= 10) {
58 buttons = DIALOG_CHOICES;
59 OnePage = "Yes";
60 }
61 else {
62 integer nPages = (N_DIALOG_CHOICES+MAX_DIALOG_CHOICES_PER_PG-1)/MAX_DIALOG_CHOICES_PER_PG;
63
64
65 if(pageNum < 1 || pageNum > nPages) {
66 pageNum = 1;
67 }
68 firstChoice = (pageNum-1)*MAX_DIALOG_CHOICES_PER_PG;
69
70 lastChoice = firstChoice+MAX_DIALOG_CHOICES_PER_PG-1;
71
72
73 if(lastChoice >= N_DIALOG_CHOICES) {
74 lastChoice = N_DIALOG_CHOICES;
75 }
76 if(pageNum <= 1) {
77 prevPage = nPages;
78 nextPage = 2;
79 }
80 else if(pageNum >= nPages) {
81 prevPage = nPages-1;
82 nextPage = 1;
83 }
84 else {
85 prevPage = pageNum-1;
86 nextPage = pageNum+1;
87 }
88 buttons = llList2List(DIALOG_CHOICES, firstChoice, lastChoice);
89 }
90
91
92 // FYI, this puts the navigation button row first, so it is always at the bottom of the dialog
93 list buttons01 = llList2List(buttons, 0, 2);
94 list buttons02 = llList2List(buttons, 3, 5);
95 list buttons03 = llList2List(buttons, 6, 8);
96 list buttons04;
97 if(OnePage == "Yes") {
98 buttons04 = llList2List(buttons, 9, 11);
99 }
100 buttons = buttons04 + buttons03 + buttons02 + buttons01;
101
102 if(OnePage == "Yes") {
103 buttons = [ DIALOG_DONE_BTN, DIALOG_BACK_BTN ]+ buttons;
104 //omit DIALOG_BACK_BTN in line above if not offering
105
106 }
107 else {
108 buttons = [
109 PREV_PG_DIALOG_PREFIX + (string)prevPage,
110 DIALOG_BACK_BTN, NEXT_PG_DIALOG_PREFIX+(string)nextPage, DIALOG_DONE_BTN
111 ]+buttons;
112 //omit DIALOG_BACK_BTN in line above if not offering
113 }
114 llDialog(ID, "Page "+(string)pageNum+"\nChoose one:", buttons, menuChannel);
115 }
116
117
118 CancelListen() {
119 llListenRemove(listen_id);
120 llSetTimerEvent(3600);
121 mode = TRUE;
122 }
123
124
125 list shrink(list in)
126 {
127 list out;
128 integer i;
130 for (; i < j; i++)
131 {
132 out += llGetSubString( llList2String(in,i), 0, 23);// V1.1 longer names
133 }
134 return out;
135 }
136
137 setStation()
138 {
139 llOwnerSay("Station set to " + genre + ":" + station + ":" + url);
141 }
142
143 getCategories()
144 {
145 type = 1;
146 busy = TRUE;
147 string url = "http://www.outworldz.com/cgi/shoutcast.plx?search=1";
148 http_request_id = llHTTPRequest(url, [], "");
149 }
150
151 getCategory()
152 {
153 type = 2;
154 busy = TRUE;
155 string url = "http://www.outworldz.com/cgi/shoutcast.plx?genre=" + llEscapeURL(genre);
156
157 // llOwnerSay(url);
158
159 http_request_id = llHTTPRequest(url, [], "");
160 }
161
162 getURL()
163 {
164 type = 3;
165 busy = TRUE;
166 string url = "http://www.outworldz.com/cgi/shoutcast.plx?genre=" + llEscapeURL(genre) + "&station=" + llEscapeURL(station);
167
168 //llOwnerSay(url);
169
170 http_request_id = llHTTPRequest(url, [], "");
171 }
172
173
174
175 default {
176
177 on_rez(integer start_param)
178 {
180 }
181
183 {
184 getCategories();
185 pageNum = 1;
186 }
187
188
189
190 touch_start(integer touchNumber)
191 {
192 user = llDetectedKey(0);
193 if(!busy)
194 {
195 DIALOG_CHOICES = [pubpriv,"Categories","Show URL"];
196 giveDialog(user, pageNum);
197 }
198 else
199 {
200 llOwnerSay("Still loading stations, please wait a moment");
201 }
202 }
203
204 listen(integer channel, string name, key id, string message)
205 {
206 integer where ;
207 if(message == "-")
208 {
209 giveDialog(user, pageNum);
210 }
211 else if( message == DIALOG_DONE_BTN)
212 {
213 CancelListen();
214 return;
215 }
216 else if(message == DIALOG_BACK_BTN)
217 {
218 pageNum = 1;
219
220 DIALOG_CHOICES = lCategories;
221 giveDialog(user, pageNum);
222 }
223 else if(llSubStringIndex(message, PREV_PG_DIALOG_PREFIX) == 0)
224 {
225 pageNum = (integer)llGetSubString(message, llStringLength(PREV_PG_DIALOG_PREFIX), -1);
226 giveDialog(user, pageNum);
227 }
228 else if(llSubStringIndex(message, NEXT_PG_DIALOG_PREFIX) == 0)
229 {
230 pageNum = (integer)llGetSubString(message, llStringLength(NEXT_PG_DIALOG_PREFIX), -1);
231 giveDialog(user, pageNum);
232
233 } else { //this is the section where you do stuff
234 if(message == "Categories")
235 {
236 DIALOG_CHOICES = lCategories;
237 giveDialog(user, pageNum);
238 }
239 else if(message == "Public")
240 {
241 pubpriv = "Private";
242 pageNum = 1;
243 DIALOG_CHOICES = lCategories;
244 giveDialog(user, pageNum);
245
246 }
247 else if(message == "Private")
248 {
249 pubpriv = "Public";
250 DIALOG_CHOICES = lCategories;
251 pageNum = 1;
252 giveDialog(user, pageNum);
253 }
254 else if(message == "Show URL")
255 {
256 string url = llGetParcelMusicURL();
257 if(pubpriv == "Public")
258 {
259 llSay(0,"Parcel URL is " + url);
260 }
261 else
262 {
263 llOwnerSay("Parcel URL is " + url);
264 }
265
266 pageNum = 1;
267
268 giveDialog(user, pageNum);
269
270 }
271 else
272 {
273 CancelListen();
274
275 where = llListFindList(lCategories,[message]);
276 if(where >= 0)
277 {
278 genre = message;
279 getCategory();
280 return;
281 }
282
283 where = llListFindList(lStations,[message]);
284 if(where >= 0)
285 {
286 station = message;
287 getURL();
288 }
289 }
290 }
291 }
292
293 http_response(key request_id, integer status, list metadata, string body)
294 {
295 if(request_id == http_request_id)
296 {
297 busy = FALSE;
298 if(type == 1)
299 {
300 lCategories = llParseString2List(body,["|"],[]);
301 lCategories= shrink(lCategories);
302 DIALOG_CHOICES = lCategories;
303
304 }
305 else if(type == 2)
306 {
307 lStations = llParseString2List(body,["|"],[]);
308 lStations= shrink(lStations);
309 DIALOG_CHOICES = lStations;
310 pageNum = 1;
311 giveDialog(user, pageNum);
312 }
313 else if(type == 3)
314 {
315 url = body;
316 setStation();
317 }
318
319 }
320 }
321
322
323 timer()
324 {
325 if(mode)
326 {
327 getCategories() ;
328 }
329 else
330 {
331 llListenRemove(listen_id);
332 llWhisper(0, "Sorry. The menu timed out, click me again to change stations.");
333 mode = TRUE;
334 llSetTimerEvent(3600.0); //Stop the timer from being called repeatedly
335 }
336
337 }
338
339 }

Top2000_Radio_Stations_Player

This is a slave for remote pacels. It listens for commands from the master controller.
More information on this radio player is at http://www.outworldz.com/Secondlife/posts/streaming

Category: Radio
By : Ferd Frederix
Created: 2013-12-14 Edited: 2017-03-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 default {
4 {
5 llListen(-95487,"","","");
6 }
7 listen(integer channel,string name, key id, string message)
8 {
9 llSetParcelMusicURL(message);
10 }
11 }

Top2000_Radio_Stations_Player

Media-On-A-Prim Radio station with several thousand stations.
You must deed this to a group if you are on group-owned Land.

Category: Radio
By : Ferd Frederix
Created: 2013-12-14 Edited: 2017-03-24
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // :License: CC-BY-NC-SA - Not to be sold in any form, Copyright 2015 Ferd Frederix
2
3 // Please do not change the timeouts or URLS - this script is server dependent.
4
5 integer debug = FALSE;
6 float version = 1.1;
7
8
9 string requestURL; // HTTP-IN URL
10 key http_request_id; // the key we search for
11 key selfCheckRequestId;// the key we search for
12
13 string mediaURI ; // saved URI for radio
14 string Description ; // saved URI for radio
15
16
17 float newTimer = 0; // how long to play a piece of music
18
19 string url = "http://www.outworldz.com";
20 string HTTPIN;
21
22
23 DEBUG(string str)
24 {
25 if(debug) llSay(0,str);
26 }
27
28 // ###############################################
29 // Routine to parse a string sent through the
30 // http server via post.
31 // parsePostData(theMessage)
32 // Returns a strided list with stride length 2.
33 // Each set has the key and then its value.
34 list parsePostData(string message) {
35 list postData = []; // The list with the data that was passed in.
36 list parsedMessage = llParseString2List(message,["&"],[]); // The key/value pairs parsed into one list.
37 integer len = ~llGetListLength(parsedMessage);
38
39 while(++len) {
40 string currentField = llList2String(parsedMessage, len); // Current key/value pair as a string.
41
42 integer split = llSubStringIndex(currentField,"="); // Find the "=" sign
43 if(split == -1) { // There is only one field in this part of the message.
44 postData += [llUnescapeURL(currentField),""];
45 } else {
46 postData += [llUnescapeURL(llDeleteSubString(currentField,split,-1)), llUnescapeURL(llDeleteSubString(currentField,0,split))];
47 }
48 }
49 // Return the strided list.
50 return postData ;
51 }
52
53 // get from list the value of the name
54 string Get( string name, list data)
55 {
56 integer index =llListFindList(data,[name]);
57 if(index == -1)
58 return "Nothing";
59 return llList2String(data,index+1);
60 }
61
62 DoWebPage(integer onOff)
63 {
64 if(! onOff)
65 {
66 llClearPrimMedia(1);
67 llOwnerSay("Touch power button to activate");
68 }
69 else
70 {
71 string lURL = url + "/radio?URI=" + llEscapeURL(HTTPIN);
72
73 DEBUG("lSetting Media URL to : " + lURL);
74 llOwnerSay("Touch screen to view. Shared media must be enabled in the Setup Menu (Ctrl-P)");
75 llSetPrimMediaParams(1,[PRIM_MEDIA_CONTROLS,PRIM_MEDIA_CONTROLS_MINI,
76 PRIM_MEDIA_HOME_URL,lURL,
77 PRIM_MEDIA_CURRENT_URL ,lURL,
78 PRIM_MEDIA_AUTO_PLAY , TRUE,
79 PRIM_MEDIA_AUTO_ZOOM, TRUE,
80 PRIM_MEDIA_WIDTH_PIXELS, 1200,
81 PRIM_MEDIA_HEIGHT_PIXELS ,750,
82 PRIM_MEDIA_AUTO_SCALE, TRUE
83
84 // PRIM_MEDIA_WHITELIST_ENABLE ,TRUE
85 // PRIM_MEDIA_WHITELIST, llEscapeURL(url),
86 // PRIM_MEDIA_PERMS_INTERACT ,PRIM_MEDIA_PERM_GROUP
87 // PRIM_MEDIA_PERMS_CONTROL ,PRIM_MEDIA_PERM_GROUP
88
89
90 ]);
91 }
92 }
93
94 string strReplace(string str, string search, string replace) {
95 return llDumpList2String(llParseStringKeepNulls((str = "") + str, [search], []), replace);
96 }
97
98 request_url()
99 {
100 llReleaseURL(HTTPIN);
101 HTTPIN = "";
102
103 http_request_id = llRequestURL(); // Request that an URL be assigned to me.
104 DEBUG("http_request_id:" + (string)http_request_id);
105 }
106
107
108 SaveToServer()
109 {
110 string newurl = url + "cgi/shoutcast2.plx?description="
111 + llEscapeURL(Description)
112 + "&mediaURI=" + llEscapeURL(mediaURI)
113 + "&version=" + llEscapeURL((string) version);
114 DEBUG("NewURL:" + newurl);
115 http_request_id = llHTTPRequest(newurl, [], "");
116 }
117
118 default {
119
120 state_entry() {
121
122 // Make it a pretty gray
123 llSetLinkPrimitiveParamsFast(0,[PRIM_TEXTURE, ALL_SIDES, "", <.5,.8,0>, <.75,.1,0>, 0, PRIM_FULLBRIGHT, 1,TRUE]);
124 llSetColor(<0.1,0.1,0.1>,ALL_SIDES);
125 llSetColor(<1,1,1>,1);
126
127
128
129
130 request_url();
132 }
133
134 timer()
135 {
136 llSetTimerEvent(3600); // hourly
137
138 if(newTimer)
139 {
140 DEBUG("Timer set to regular channel");
141 llSetParcelMusicURL(mediaURI);
142 newTimer = FALSE;
143
144 return;
145 }
146 if(llStringLength(requestURL))
147 {
148 DEBUG("timer:" + (string) requestURL);
149 selfCheckRequestId = llHTTPRequest(requestURL,[],"");
150 }
151
152 }
153
155 {
156 key id = llDetectedKey(0);
157
158 integer sameGroup = llSameGroup(id);
159 if(sameGroup) {
160 DoWebPage(TRUE);
161 }
162 }
163
164 http_response(key id, integer status, list metaData, string body)
165 {
166 DEBUG("ID:" + (string) id);
167 DEBUG("selfCheckRequestId:" + (string) selfCheckRequestId);
168
169 if(id == selfCheckRequestId)
170 {
171 // If you're not usually doing this,
172 // now is a good time to get used to doing it!
173 selfCheckRequestId = NULL_KEY;
174
175 if(status != 200)
176 request_url();
177 }
178
179 else if(id == NULL_KEY)
180 llOwnerSay("Too many HTTP requests too fast!");
181 }
182
183 http_request(key id, string method, string body) {
184
185 DEBUG("http_request:" + body);
186 list incomingMessage;
187
188 if((method == URL_REQUEST_GRANTED) && (id == http_request_id) ){
189 // A URL has been assigned to me.
190 HTTPIN = body;
191 DEBUG("Obtained URL: " + body);
192 DoWebPage(TRUE);
193 }
194 else if((method == URL_REQUEST_DENIED) && (id == http_request_id)) {
195 // I could not obtain a URL
196 llOwnerSay("The following error occurred while attempting to get a free URL for this device: " + body);
197
198 llSleep(60);
199 llOwnerSay("Retrying in one minute");
201 }
202 else if(method == "POST") {
203 // An incoming message was received.
204 DEBUG("Received information from the outside: " + body);
205 //src=Fred+Beckusen&name=A.RADIO00sJUICE&id=http%3A%2F%2Fstreaming208.radionomy.com%3A80%2FA-RADIO-00s-JUICE
206
207 incomingMessage = parsePostData(body);
208 DEBUG(llDumpList2String(incomingMessage,"\n"));
209
210 mediaURI = Get("id",incomingMessage);
211 Description = Get("name",incomingMessage);
212 Description = strReplace(Description,"+"," ");
213 llOwnerSay("Station changed to " + Description +"\n" + llUnescapeURL(mediaURI));
214
215 DEBUG("Set Media URL on land to " + mediaURI);
216 llSetParcelMusicURL(mediaURI);
217
218 if(llList2String(incomingMessage,0) == "power")
219 DoWebPage(FALSE);
220
221
222 llHTTPResponse(id,200,"OK:" + llDumpList2String(incomingMessage,"\n"));
223
224 }
225 else {
226 // An incoming message has come in using a method that has
227 // not been anticipated.
228 llHTTPResponse(id,405,"Unsupported Method");
229 }
230 }
231
232 changed(integer change)
233 {
234 if(change & CHANGED_REGION_START)
235 request_url();
236
237 }
238 }

Back to the Best Free Tools in Second Life and OpenSim.