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 Radio  

Radio

Always update large shoutcast radio system

Category: Radio
By : Ferd Frederix
Created: 2013-09-06 Edited: 2013-09-04
Worlds: Second Life

the Zip file

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

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