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
TV Media_Player  

Media_Player

RPS Media Player Script

Category: TV
By : Regina Public Schools
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Media_Player
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Media_Player_1.lsl
Get file # 2. Media_Player_2.lsl
Get file # 3. Media_Player_3.lsl
1
2 // CONFIG STUFF ********************************************************************************************************* //
3
4 // MENUS
5 integer Main_Menu_Channel = 2;
6 integer Menu_Listen;
7 list Menu_Main = ["Help", "Security", "Load Album"];
8 string MenuMain_Prompt = "Choose an option...\n\n1) Help File\n2) Screen Security\n3) Select an Album";
9 list Menu_Security = ["Everyone", "Owner", "Group"];
10 string MenuSecurity_Prompt = "Set screen security...\n\n1) Owner Only\n2) Group\n3) Everyone";
11 list Menu_Configure = ["Cancel", "Manual", "Timed"];
12 string MenuConfigure_Prompt = "Configure viewing options...\n\n1) Manual Slideshow\n2) Timed Slideshow";
13 list Menu_Slideshow = ["10", "20", "30", "40", "50", "60", "70", "80", "90"];
14 string MenuSlideshow_Prompt = "Choose a time in seconds...";
15
16 // ALBUM CHOICE
17 list MediaCards;
18 integer MaxMediaCards;
19 list MediaCardChoices;
20 integer MediaCardItems = 5;
21 string MediaCard_Prompt = "Choose a media album...";
22 integer FirstMediaCard;
23 integer i;
24 string Item_Notecard;
25
26 // SECURITY
27 integer Security = 0;
28
29 // TIMED SLIDESHOW
30 integer timed = 0;
31 string spacer = "|";
32 list slideshowdata;
33
34 // DIALOG TEXTS AND ENTRIES
35 list All_Entries;
36 list All_Entries_Descriptions;
37 list Menu_Buttons;
38
39 // DIALOG ITEMS
40 integer Line_Number = 0;
41 integer Current_Offset = 0;
42 integer Menu_Button_Items = 6;
43 integer Current_Final_Position = 5;
44 integer Total_Notecard_Entries = 0;
45 integer Menu_Loaded = 0;
46 integer Current_Item_Number = -1;
47 string Menu_Descriptions = "";
48
49 // DIALOG BUTTONS
50 string Next_Button_Text = "Next >>";
51 string Previous_Button_Text = "<< Prev";
52 string Back_Button_Text = "Cancel";
53 list Next_Command = [">>", "next", "Next", Next_Button_Text];
54 list Back_Command = [Back_Button_Text];
55 list Previous_Command = ["<<", "prev", "Prev", Previous_Button_Text];
56 string Current_Set = "c";
57 string All_Sets = "a";
58
59 // DATA FROM DIALOG CHOICE
60 string Current_Item_URL;
61 string Item_Description;
62 string Image_Feed = "";
63
64 // COMMUNICATION CHANNELS
65 integer Video_Start = 0;
66 integer Video_Stop = 0;
67
68 // HELP MESSAGE WHISPERED AT STARTUP
69 string Help_Message = "Click the remote to select a media file";
70
71 // AVATAR DETAILS
72 key Avatar_Using;
73
74
75
76 // USER-DEFINED FUNCTIONS *********************************************************************************************** //
77
78 reset()
79 {
80 Video_Start = (integer) llGetObjectDesc();
81 Video_Stop = Video_Start+20;
82 Main_Menu_Channel = Video_Start+400;
83 llSetObjectName("RPS Media Remote V6.0");
84 llListenRemove(Menu_Listen);
85 Menu_Listen = llListen(Main_Menu_Channel, "", NULL_KEY, "");
86 llSetText("RPS Video\n"+Item_Description,<1.0,1.0,1.0>,1.0);
87 }
88
89 ShowNotecardMenu()
90 {
91 MediaCardChoices = [ ];
92 if(FirstMediaCard > 0)
93 MediaCardChoices += "<<";
94 if(MaxMediaCards > (FirstMediaCard + MediaCardItems))
95 {
96 MediaCardChoices += ">>";
97 MediaCardChoices += "Cancel";
98 }
99 for(i = 0;i < MediaCardItems;i++)
100 {
101 integer j = (i + FirstMediaCard);
102 string num = (string)j;
103 string strname = llList2String(MediaCards,j);
104 if( llStringLength(strname) > 0)
105 {
106 MediaCardChoices = (list)strname + MediaCardChoices;
107 }
108 }
109 llDialog(Avatar_Using, MediaCard_Prompt, MediaCardChoices, Main_Menu_Channel);
110 }
111
112 GetNotecardList()
113 {
114 MediaCards = [];
116 while(--number >= 0)
117 {
119 MediaCards = (MediaCards = []) + MediaCards + [ name ];
120 }
121 }
122
123 AddInventoryItem(string line)
124 {
125 if(llGetSubString(line,0,0)=="#")
126 {
127 return;
128 }
129 list Notecard_Entry_List = llParseString2List(line, ["|"], []);
130 if(llGetListLength(Notecard_Entry_List) < 2)
131 {
132 return;
133 }
134 string locationDesc = llList2String(Notecard_Entry_List,0);
135 string location = llList2String(Notecard_Entry_List,1);
136 All_Entries += [location];
137 All_Entries_Descriptions += [locationDesc];
138 }
139
140 DoCurrentEntries()
141 {
142 Menu_Buttons = [Back_Button_Text, Previous_Button_Text, Next_Button_Text];
143 integer i;
144 Menu_Descriptions = "";
145 for (i = Current_Offset; i <= Current_Final_Position; i++)
146 {
147 if(Current_Item_Number == i)
148 {
149 Menu_Descriptions += "*";
150 }
151 else
152 {
153 Menu_Descriptions += " ";
154 }
155 Menu_Descriptions += (string) (i + 1) + ") ";
156 Menu_Descriptions += llList2String(All_Entries_Descriptions, i);
157 Menu_Descriptions += "\n";
158 Menu_Buttons += (string)(i + 1);
159 }
160 }
161
162 DoNextEntries()
163 {
164 Current_Offset += Menu_Button_Items;
165 Current_Final_Position = Current_Offset + (Menu_Button_Items - 1);
166 if(Current_Offset >= Total_Notecard_Entries)
167 {
168 Current_Offset = 0;
169 Current_Final_Position = Current_Offset + (Menu_Button_Items - 1);
170 }
171 if(Current_Final_Position >= Total_Notecard_Entries)
172 {
173 Current_Final_Position = Total_Notecard_Entries - 1;
174 }
175 }
176
177 DoPreviousEntries()
178 {
179 if(Current_Offset > 1 && ((Current_Offset - Menu_Button_Items) < 1))
180 {
181 Current_Offset = 0;
182 }
183 else
184 {
185 Current_Offset -= Menu_Button_Items;
186 }
187 Current_Final_Position = Current_Offset + (Menu_Button_Items - 1);
188 if(Current_Final_Position >= Total_Notecard_Entries)
189 {
190 Current_Final_Position = Total_Notecard_Entries - 1;
191 }
192 if(Current_Offset < 0)
193 {
194 Current_Final_Position = Total_Notecard_Entries - 1;
195 Current_Offset = Total_Notecard_Entries - (Menu_Button_Items - 1);
196 }
197 }
198
199
200 // START **************************************************************************************************************** //
201
202 default
203 {
204 on_rez(integer start_param)
205 {
206 reset();
207 }
208
210 {
211 reset();
212 }
213
214 changed(integer change)
215 {
216 if((change & CHANGED_OWNER) || (change & CHANGED_INVENTORY))
217 {
218 reset();
219 }
220 }
221
222 touch_start(integer total_number)
223 {
224 Avatar_Using = llDetectedKey(0);
225 if((Security==0 && Avatar_Using==llGetOwner()) || (Security==1 && llSameGroup(Avatar_Using)) || Security==2)
226 {
227 llDialog(Avatar_Using, MenuMain_Prompt, Menu_Main, Main_Menu_Channel);
228 }
229 else
230 {
231 llSay(0, "You don't have permission to use this screen...");
232 }
233 }
234
235 listen(integer channel, string name, key id, string message)
236 {
237 if(message == "Help")
238 {
239 llLoadURL(Avatar_Using, "Web Media User Guide", "http://www.theconsultants-e.com/edunation/edunationtoolsmediaviewer.asp");
240 }
241 else if(message == "Security")
242 {
243 state security;
244 }
245 else if(message == "Load Album")
246 {
247 state loadshow;
248 }
249 else
250 llSay(0, name + " picked invalid option '" + llToLower(message) + "'.");
251 }
252 }
253
254
255 // ******************** LOAD SHOW STATE ******************** //
256 // MENU TO CHOOSE A MEDIA SHOW NOTECARD ******************** //
257
258 // THIS NEEDS THEM TO SHOW ALHPABETICALLY - ANY IDEAS????
259
260 state loadshow
261 {
263 {
264 llListenRemove(Menu_Listen);
265 Menu_Listen = llListen(Main_Menu_Channel, "", NULL_KEY, "");
266 GetNotecardList();
267 MaxMediaCards = llGetListLength(MediaCards);
268 FirstMediaCard = 0;
269 ShowNotecardMenu();
270 }
271
272 listen(integer channel, string name, key id, string message)
273 {
274 if("<<" == message)
275 {
276 FirstMediaCard -= MediaCardItems;
277 if(FirstMediaCard < 0) FirstMediaCard = 0;
278 ShowNotecardMenu();
279 }
280
281 else if(">>" == message)
282 {
283 FirstMediaCard += MediaCardItems;
284 if(FirstMediaCard > MaxMediaCards) FirstMediaCard = (MaxMediaCards - MediaCardItems);
285 ShowNotecardMenu();
286 }
287 else if("Cancel" == message)
288 {
289 state remenu;
290 }
291 else
292 {
293 integer index = llListFindList(MediaCards, [message]);
294 if(index >= 0)
295 {
296 string NotecardName = llList2String(MediaCards,index);
297 Item_Notecard = NotecardName;
298 state configureshow;
299 }
300 }
301 }
302 }
303
304 // ******************** SECURITY STATE ******************** //
305 // USED TO SET THE SECURITY OF THE SCREEN - 3 LEVEL ACCESS //
306
307 state security
308 {
310 {
311 llListenRemove(Menu_Listen);
312 Menu_Listen = llListen(Main_Menu_Channel, "", NULL_KEY, "");
313 llDialog(Avatar_Using, MenuSecurity_Prompt, Menu_Security, Main_Menu_Channel);
314 }
315
316 listen(integer channel, string name, key id, string message)
317 {
318 if(message == "Owner")
319 {
320 Security = 0;
321 llInstantMessage(Avatar_Using, "Screen permissions set to Owner...");
322 state remenu;
323 }
324 else if(message == "Group")
325 {
326 Security = 1;
327 llInstantMessage(Avatar_Using, "Screen permissions set to Group...");
328 state remenu;
329 }
330 else if(message == "Everyone")
331 {
332 Security = 2;
333 llInstantMessage(Avatar_Using, "Screen permissions set to Everyone...");
334 state remenu;
335 }
336 else
337 llSay(0, name + " picked invalid option '" + llToLower(message) + "'.");
338 }
339 }
340
341
342 // ******************** CONFIGURE STATE ******************** //
343 // USED TO CONFIGURE EITHER MANUAL OR TIMES SLIDESHOW MODES //
344
345 state configureshow
346 {
348 {
349 llListenRemove(Menu_Listen);
350 Menu_Listen = llListen(Main_Menu_Channel, "", NULL_KEY, "");
351 llDialog(Avatar_Using, MenuConfigure_Prompt, Menu_Configure, Main_Menu_Channel);
352 }
353
354 listen(integer channel, string name, key id, string message)
355 {
356 if(message == "Manual")
357 {
358 state manualshow;
359 }
360 else if(message == "Timed")
361 {
362 state slideshow;
363 }
364 else if(message == "Cancel")
365 {
366 state remenu;
367 }
368 else
369 llSay(0, name + " picked invalid option '" + llToLower(message) + "'.");
370 }
371 }
372
373
374 // ******************** MANUAL SHOW STATE ******************** //
375 // MANUAL SLIDESHOW MODE - USER CHOOSES WHICH MEDIA TO SHOW //
376
377
378 state manualshow
379 {
381 {
382 llListenRemove(Menu_Listen);
383 Current_Offset = 0;
384 Current_Final_Position = 5;
385 Line_Number = 0;
386 Menu_Loaded = 0;
387 All_Entries = [];
388 All_Entries_Descriptions = [];
389 Total_Notecard_Entries = 0;
390 Current_Item_Number = -1;
391 Menu_Descriptions = "";
392 llGetNotecardLine(Item_Notecard, Line_Number);
393 }
394
395 dataserver(key query_id, string data)
396 {
397 if(data != EOF)
398 {
399 AddInventoryItem(data);
400 Line_Number++;
401 llGetNotecardLine(Item_Notecard, Line_Number);
402 return;
403 }
404 llListen(Main_Menu_Channel, "", NULL_KEY, "");
405 Total_Notecard_Entries = llGetListLength(All_Entries);
406 llSay(0, Help_Message);
407 Menu_Loaded = 1;
408 }
409
410 touch_start(integer touchNumber)
411 {
412 DoCurrentEntries();
413 Avatar_Using = llDetectedKey(0);
414 llDialog(Avatar_Using, Menu_Descriptions, Menu_Buttons, Main_Menu_Channel);
415 }
416
417 listen(integer channel, string name, key id, string message)
418 {
419 if(Menu_Loaded == 0)
420 {
421 llWhisper(0, " ... still loading ...");
422 return;
423 }
424 Avatar_Using = id;
425 list Notecard_Entry_List = llParseString2List(message, [" ", " ", "|"], []);
426 list testFind = llList2List(Notecard_Entry_List, 0, 0);
427 if(message == "")
428 {
429 message = "cur";
430 }
431 if(llListFindList(Next_Command, testFind) != -1)
432 {
433 DoNextEntries();
434 DoCurrentEntries();
435 llDialog(id, Menu_Descriptions, Menu_Buttons, Main_Menu_Channel);
436 return;
437 }
438 else if(llListFindList(Previous_Command, testFind) != -1)
439 {
440 DoPreviousEntries();
441 DoCurrentEntries();
442 llDialog(id, Menu_Descriptions, Menu_Buttons, Main_Menu_Channel);
443 return;
444 }
445 else if(llListFindList(Back_Command, testFind) != -1)
446 {
447 state remenu;
448 }
449
450 else if((integer)message > 0 && (integer)message < 256)
451 {
452 llSay(Video_Stop,"Stop video");
453 Current_Item_Number = (integer)message - 1;
454 Current_Item_URL = llList2String(All_Entries, Current_Item_Number);
455 Item_Description = llList2String(All_Entries_Descriptions, Current_Item_Number);
456 Image_Feed = "";
457 llSleep(0.25);
458 llSay(Video_Start,Current_Item_URL);
459 llSetText("RPS Video\n"+Item_Description,<1.0,1.0,1.0>,1.0);
460 }
461
462 else
463 state remenu;
464 }
465 }
466
467
468 // ******************** SLIDESHOW STATE ******************** //
469 // USED TO CONFIGURE TIMED SLIDESHOW - INCREMENT 10 SECONDS //
470
471 // THIS NEEDS TO START IMMEDIATELY RATHER THAN AFTER THE FIRST TMER EVENT - ANY IDEAS?????
472
473 state slideshow
474 {
476 {
477 llListenRemove(Menu_Listen);
478 Menu_Listen = llListen(Main_Menu_Channel, "", NULL_KEY, "");
479 llDialog(Avatar_Using, MenuSlideshow_Prompt, Menu_Slideshow, Main_Menu_Channel);
480 }
481
482 listen(integer channel, string name, key id, string message)
483 {
484 if((integer)message > 0 && (integer)message < 100)
485 {
486 llSay(0, "Slideshow starting. Frequency: " +message + " seconds...");
487 llSetTimerEvent((integer)message);
488 }
489 else
490 llSay(0, name + " picked invalid option '" + llToLower(message) + "'.");
491 }
492
493 timer()
494 {
495 llGetNotecardLine(Item_Notecard, Line_Number);
496 }
497
498 dataserver(key id, string data)
499 {
500 if(data==EOF)
501 {
502 Line_Number=1;
503 }
504
505 else
506 {
507 llSay(Video_Stop,"Stop video");
508 slideshowdata = llParseString2List(data,[spacer],[]);
509 Current_Item_URL = llList2String(slideshowdata,1);
510 llSay(0, Current_Item_URL);
511 llSay(Video_Start,Current_Item_URL);
512 llSetText("RPS Video\n"+Item_Description,<1.0,1.0,1.0>,1.0);
513 ++Line_Number;
514 }
515 }
516
517 touch_start(integer touchNumber)
518 {
519 state remenu;
520 }
521 }
522
523
524 // ******************** REMENU STATE ******************** //
525 // SIMPLE RECALL OF THE ORIGINAL MENU WITH NO TOUCH START //
526
527 state remenu
528 {
530 {
531 llListenRemove(Menu_Listen);
532 Menu_Listen = llListen(Main_Menu_Channel, "", NULL_KEY, "");
533 llDialog(Avatar_Using, MenuMain_Prompt, Menu_Main, Main_Menu_Channel);
534 }
535
536 listen(integer channel, string name, key id, string message)
537 {
538 if(message == "Help")
539 {
540 llLoadURL(Avatar_Using, "Web Media User Guide", "http://www.theconsultants-e.com/edunation/edunationtoolsmediaviewer.asp");
541 }
542 else if(message == "Security")
543 {
544 state security;
545 }
546 else if(message == "Load Album")
547 {
548 state loadshow;
549 }
550 else
551 llSay(0, name + " picked invalid option '" + llToLower(message) + "'.");
552 }
553 }

Media_Player

Videos Notecard

Category: TV
By : Regina Public Schools
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 Residential Schools | http://webfiles.rbe.sk.ca/rps/marnie.mcmillan/poppy.mov

Media_Player

Screen Script

Category: TV
By : Regina Public Schools
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

1 integer VIDEO_START;
2 integer VIDEO_STOP;
3 integer LISTEN_VIDEO_START;
4 integer LISTEN_VIDEO_STOP;
5
6 string TrimRight(string src, string chrs)//Mono Unsafe, LSO Safe
7 {
8 integer i = llStringLength(src);
9 do {} while(~llSubStringIndex(chrs, llGetSubString(src, i = ~-i, i)) && i);
10 return llDeleteSubString(src, -~(i), 0x7FFFFFF0);
11 }
12
13 string TrimLeft(string src, string chrs)//Mono Unsafe, LSO Safe
14 {
15 integer i = ~llStringLength(src);
16 do {} while(i && ~llSubStringIndex(chrs, llGetSubString(src, i = -~i, i)));
17 return llDeleteSubString(src, 0x8000000F, ~-(i));
18 }
19
20 string TrimBoth(string src, string chrs)//Mono Unsafe, LSO Safe
21 {
22 integer i = ~llStringLength(src);
23 do {} while(i && ~llSubStringIndex(chrs, llGetSubString(src, i = -~i, i)));
24 i = llStringLength(src = llDeleteSubString(src, 0x8000000F, ~-(i)));
25 do {} while(~llSubStringIndex(chrs, llGetSubString(src, i = ~-i, i)) && i);
26 return llDeleteSubString(src, -~(i), 0x7FFFFFF0);
27 }
28
29
30
31
32 reset()
33 {
34 llSetText("",<0,0,0>,0);
35 llListenRemove(LISTEN_VIDEO_START);
36 llListenRemove(LISTEN_VIDEO_STOP);
37 VIDEO_START = (integer) llGetObjectDesc();
38 VIDEO_STOP = VIDEO_START+20;
39 LISTEN_VIDEO_START = llListen(VIDEO_START, "", NULL_KEY, "");
40 LISTEN_VIDEO_STOP = llListen(VIDEO_STOP,"",NULL_KEY,"");
41 llSetObjectName("RPS Media V6.0");
43 if(llGetListLength(owned)==0)
44 llWhisper(0, "Please deed me [ land owner and my owner must be the same ].");
45 }
46
47 default
48 {
49 on_rez(integer start_param)
50 {
51 reset();
52 }
53
55 {
56 reset();
57 }
58
59 listen(integer channel, string name, key id, string message)
60 {
61 if(channel == VIDEO_STOP)
62 {
64 }
65 else if(channel == VIDEO_START)
66 {
67 string mimetype="text/html";
68 string code = "text/html";
69 string URL = TrimBoth(message," ");
70 string protocol = TrimBoth(llToLower(llGetSubString(message,0,4))," ");
71 string ext = TrimBoth(llToLower(llGetSubString(message,-3,-1))," ");
72 if(protocol == "rtsp") {
73 code = "rtsp";
74 } else {
75 if(ext == "sdp") code="application/sdp";
76 if(ext == "mil") code="application/smil";
77 if(ext == "mov") code="video/quicktime";
78 if(ext == "avi") code="video/quicktime";
79 if(ext == "m4v") code="video/quicktime";
80 if(ext == "mpg") code="video/mpeg";
81 if(ext == ".qt") code="video/quicktime";
82 if(ext == "flc") code="video/flc";
83 if(ext == "mp4") code="video/mp4";
84 if(ext == "sdv") code="video/sd-video";
85 if(ext == "aac") code="audio/aac";
86 if(ext == "m4p") code="audio/x-m4p";
87 if(ext == "m4a") code="audio/x-m4a";
88 if(ext == "m4b") code="audio/x-m4b";
89 if(ext == "mp3") code="audio/mp3";
90 if(ext == "3gp") code="audio/3gpp";
91 if(ext == "gif") code="image/gif";
92 if(ext == "png") code="image/png";
93 if(ext == "peg") code="image/jpeg";
94 if(ext == "tga") code="image/tga";
95 if(ext == "jpg") code="image/jpeg";
96 }
97 llSay(0, code);llSay(0,ext);
101 // ,PARCEL_MEDIA_COMMAND_SIZE, 800, 600
102 ]);
103 llSleep(1.0);
105 }
106 }
107 }

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