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 FreeView_12_WebGuide_TV_Set  

FreeView_12_WebGuide_TV_Set

FreeView_12_WebGuide_TV_Set

Category: TV
By : CrystalShard Foo
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for FreeView_12_WebGuide_TV_Set
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. FreeView_12_WebGuide_TV_Set_1.lsl
1 /FreeView 1.2 WebGuide - By CrystalShard Foo
2 //Multifunctional Picture viewer and Video control script with webguide support
3 //This script is distributed for free and must stay that way. DO NOT SELL THIS SCRIPT UNDER ANY CIRCUMSTANCE.
4
5 //Help for using this script can be obtained at: http://www.slguide.com/help
6
7 //Feel free to modify this script and post your improvement. Leave the credits intact but feel free to add your name at its bottom.
8
9
10 //Constants
11 integer PICTURE_ROTATION_TIMER = 30; //In whole seconds
12
13 integer DISPLAY_ON_SIDE = ALL_SIDES; //Change this to change where the image will be displayed
14
15 key VIDEO_DEFAULT = "6e0f05ad-1809-4edc-df29-fae3d2a6c9b8"; //Test pattern - Used as default video texture when one is missing in parcel media
16 key BLANK = "5748decc-f629-461c-9a36-a35a221fe21f"; //Blank texture - Used when there are no textures to display in Picture mode
17 string NOTECARD = "bookmarks"; //Used to host URL bookmarks for video streams
18
19 integer VIDEO_MATERIAL = PRIM_MATERIAL_LIGHT; //Note - Side 0 automaticly gets colored <0,0,0> to prevent light lag!
20 integer PICTURE_MATERIAL = PRIM_MATERIAL_LIGHT; //All this does is make the prim bright. No worries about light related lag.
21
22 integer REMOTE_CHANNEL = 9238742;
23
24 integer mode = 0; //Freeview mode.
25 //Mode 0 - Power off
26 //Mode 1 - Picture viewer
27 //Mode 2 - Video
28
29 integer listenHandle = -1; //Dialog menu listen handler
30 integer listenUrl = -1; //listen handler for channel 1 for when a URL is being added
31 integer listenTimer = -1; //Timer variable for removing all listeners after 2 minutes of listener inactivity
32 integer listenRemote = -1; //listen handler for the remote during initial setup
33 integer encryption = 0;
34 integer numberofnotecardlines = 0; //Stores the current number of detected notecard lines.
35 integer notecardline = 0; //Current notecard line
36
37 integer loop_image = FALSE; //Are we looping pictures with a timer? (picture mode)
38 integer current_texture = 0; //Current texture number in inventory being displayed (picture mode)
39 integer chan; //llDialog listen channel
40 integer notecardcheck = 0;
41 key video_texture; //Currently used video display texture for parcel media stream
42
43 string moviename;
44 string tempmoviename;
45 key notecardkey = NULL_KEY;
46 key tempuser; //Temp key storge variable
47 string tempurl; //Temp string storge variable
48
49 integer isGroup = TRUE;
50 key groupcheck = NULL_KEY;
51 key last_owner;
52 key XML_channel;
53
54 pictures() //Change mode to Picture Viewer
55 {
56 //Initilize variables
57
58 //Change prim to Light material while coloring face 0 black to prevent light-lag generation.
59 llSetPrimitiveParams([PRIM_BUMP_SHINY,DISPLAY_ON_SIDE,PRIM_SHINY_NONE,PRIM_BUMP_NONE,PRIM_COLOR,DISPLAY_ON_SIDE,<1,1,1>,1.0,PRIM_MATERIAL,PICTURE_MATERIAL]);
60 llSetColor(<0,0,0>,0);
61
63
64 if(check == 0)
65 {
66 report("No pictures found.");
67 llSetTexture(BLANK,DISPLAY_ON_SIDE);
68 return;
69 }
70 else
71 if(current_texture > check)
72 //Set to first texture if available
73 current_texture = 0;
74
75 display_texture(current_texture);
76 }
77
78 video() //Change mode to Video
79 {
80 //Change prim to Light material while coloring face 0 black to prevent light-lag generation.
81 llSetPrimitiveParams([PRIM_BUMP_SHINY,DISPLAY_ON_SIDE,PRIM_SHINY_NONE,PRIM_BUMP_NONE,PRIM_COLOR,DISPLAY_ON_SIDE,<1,1,1>,1.0,PRIM_MATERIAL,VIDEO_MATERIAL,PRIM_TEXTURE,DISPLAY_ON_SIDE,"62dc73ca-265f-7ca0-0453-e2a6aa60bb6f",llGetTextureScale(DISPLAY_ON_SIDE),llGetTextureOffset(DISPLAY_ON_SIDE),llGetTextureRot(DISPLAY_ON_SIDE)]);
82 llSetColor(<0,0,0>,0);
83
84 report("Video mode"+moviename+": Stopped");
85 if(finditem(NOTECARD) != -1)
86 tempuser = llGetNumberOfNotecardLines(NOTECARD);
88 if(video_texture == NULL_KEY)
89 {
90 video_texture = VIDEO_DEFAULT;
92 llSay(0,"No parcel media texture found. Setting texture to default: "+(string)VIDEO_DEFAULT);
94 llSay(0,"Error: Cannot modify parcel media settings. "+llGetObjectName()+" is not owned by parcel owner.");
95 }
96
97 llSetTexture(video_texture,DISPLAY_ON_SIDE);
98 }
99
100 off()
101 {
102 report("Click to power on.");
103 llSetPrimitiveParams([PRIM_BUMP_SHINY,DISPLAY_ON_SIDE,PRIM_SHINY_LOW,PRIM_BUMP_NONE,PRIM_COLOR,DISPLAY_ON_SIDE,<0.1,0.1,0.1>,1.0,PRIM_MATERIAL,PRIM_MATERIAL_PLASTIC,PRIM_TEXTURE,DISPLAY_ON_SIDE,BLANK,llGetTextureScale(DISPLAY_ON_SIDE),llGetTextureOffset(DISPLAY_ON_SIDE),llGetTextureRot(DISPLAY_ON_SIDE)]);
104 }
105
106 integer finditem(string name) //Finds and returns an item's inventory number
107 {
108 integer i;
111 return i;
112 return -1;
113 }
114
115 seturl(string url, key id) //Set parcel media URL
116 {
117 if(mode != 2)
118 {
119 video();
120 mode = 2;
121 }
122 moviename = tempmoviename;
123 if(moviename)
124 moviename = " ["+moviename+"]";
125 tempmoviename = "";
127 if(oldurl != "")
128 llOwnerSay("Setting new media URL. The old URL was: "+oldurl);
129
131 if(id!=NULL_KEY)
132 menu(id);
133 else
134 {
135 report("Video mode"+moviename+": Playing");
137 }
138
139 if(isGroup)
140 llSay(0,"New media URL set.");
141 else
142 llOwnerSay("New media URL set: "+url);
143 }
144
145 string mediatype(string ext) //Returns a string stating the filetype of a file based on file extension
146 {
147 ext = llToLower(ext);
148 if(ext == "swf")
149 return "Flash";
150 if(ext == "mov" || ext == "avi" || ext == "mpg" || ext == "mpeg" || ext == "smil")
151 return "Video";
152 if(ext == "jpg" || ext == "mpeg" || ext == "gif" || ext == "png" || ext == "pict" || ext == "tga" || ext == "tiff" || ext == "sgi" || ext == "bmp")
153 return "Image";
154 if(ext == "txt")
155 return "Text";
156 return "Unknown";
157 }
158
159 browse(key id) //Image browser function for picture viewer mode
160 {
162 string header;
163 if(check > 0)
164 header = "("+(string)(current_texture+1)+"/"+(string)check+") "+llGetInventoryName(INVENTORY_TEXTURE,current_texture);
165 else
166 header = "No pictures found.";
167 llDialog(id,"** Monitor Control **\n Picture Viewer mode\n- Image browser\n- "+header,["Back","Next","Menu"],chan);
168 extendtimer();
169 }
170
171 report(string str)
172 {
173 llSetObjectDesc(str);
174 }
175
176 extendtimer() //Add another 2 minute to the Listen Removal timer (use when a Listen event is triggered)
177 {
178 if(listenHandle == -1)
179 listenHandle = llListen(chan,"","","");
180 listenTimer = (integer)llGetTime() + 120;
181 if(loop_image == FALSE)
183 }
184
185 config(key id) //Configuration menu
186 {
187 extendtimer();
188 llDialog(id,"Current media URL:\n"+llList2String(llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL]),0)+"\nTip: If the picture is abit off, try 'Align ON'",["Set URL","Align ON","Align OFF","Menu","Set Remote"],chan);
189 }
190
191 tell_remote(string str)
192 {
193 llShout(REMOTE_CHANNEL,llXorBase64Strings(llStringToBase64((string)encryption + str), llStringToBase64((string)encryption)));
194 }
195
196 menu(key id) //Dialog menus for all 3 modes
197 {
198 list buttons = [];
199 string title = "** Monitor control **";
200
201 extendtimer();
202
203 if(mode != 0)
204 {
205 if(mode == 1) //Pictures menu
206 {
207 title+="\n Picture Viewer mode";
208 buttons+=["Browse"];
209 if(loop_image == FALSE)
210 buttons+=["Loop"];
211 else
212 buttons+=["Unloop"];
213 buttons+=["Video","Power off","Help"];
214 }
215 else //Video menu
216 {
217 title+="\n Video display mode\n"+moviename+"\nTip:\nClick 'Web Guide' to view the Online bookmarks.";
218 buttons+=["Pictures","Configure","Power off","Loop","Unload","Help","Play","Stop","Pause","Web Guide","Bookmarks","Set URL"];
219 }
220 }
221 else
222 buttons += ["Pictures","Video","Help"];
223
224 llDialog(id,title,buttons,chan);
225 }
226
227 display_texture(integer check) //Display texture and set name in description (picture mode)
228 { //"Check" holds the number of textures in contents. The function uses "current_texture" to display.
229 string name = llGetInventoryName(INVENTORY_TEXTURE,current_texture);
230 llSetTexture(name,DISPLAY_ON_SIDE);
231 report("Showing picture: "+name+" ("+(string)(current_texture+1)+"/"+(string)check+")");
232 }
233
234
235 next() //Change to next texture (picture mode)
236 { //This function is used twice - by the menu and timer. Therefor, it is a dedicated function.
237 current_texture++;
239 if(check == 0)
240 {
241 llSetTexture(BLANK,DISPLAY_ON_SIDE);
242 current_texture = 0;
243 report("No pictures found.");
244 return;
245 }
246 if(check == current_texture)
247 current_texture = 0;
248
249 display_texture(check);
250 return;
251 }
252
253 default
254 {
256 {
257 chan = (integer)llFrand(1000) + 1000; //Pick a random listen channel for the listener
258 if(PICTURE_ROTATION_TIMER <= 0) //Ensure the value is no less or equal 0
259 PICTURE_ROTATION_TIMER = 1;
260 llListenRemove(listenHandle);
261 listenHandle = -1;
262 last_owner = llGetOwner();
264 off();
266 }
267
269 {
271 }
272
273 touch_start(integer total_number)
274 {
275 //-------------------------------------------------------------------------------
276 //Listen only to owner or group member. Edit this code to change access controls.
278 return;
279 //-------------------------------------------------------------------------------
280
281 if(llGetOwnerKey(llGetKey()) != last_owner) //Sense if object has been deeded to group for Web Guide function
282 {
283 isGroup = TRUE;
284 last_owner = llGetOwner();
286 }
287
288 menu(llDetectedKey(0));
289 }
290
291 changed(integer change)
292 {
293 if(change == CHANGED_INVENTORY) //If inventory change
294 if(mode == 1) //If picture mode
295 {
297 if(check != 0)
298 {
299 current_texture = 0;
300 display_texture(check);
301 }
302 else
303 {
304 llSetTexture(BLANK,DISPLAY_ON_SIDE);
305 report("No pictures found.");
306 }
307 }
308 else
309 if(mode == 2) //If video mode
310 if(finditem(NOTECARD) != -1) //And bookmarks notecard present
311 if(notecardkey != llGetInventoryKey(NOTECARD))
312 tempuser = llGetNumberOfNotecardLines(NOTECARD); //Reload number of lines
313 }
314
315 listen(integer channel, string name, key id, string message)
316 {
317 if(message == "Pictures")
318 {
319 if(mode == 2)
321 pictures();
322 mode = 1;
323 menu(id);
324 return;
325 }
326 if(message == "Video")
327 {
328 video();
329 mode = 2;
330 menu(id);
331 return;
332 }
333 if(message == "Power off")
334 {
335 if(mode == 2)
337 off();
338 mode = 0;
339 return;
340 }
341 if(message == "Help")
342 {
343 llSay(0,"Help documentation is available at: http://www.slguide.com/help");
344 if(isGroup)
345 tell_remote("HELP"+(string)id+(string)XML_channel);
346 else
347 llLoadURL(id,"Help pages for FreeView","http://www.slguide.com?c="+(string)XML_channel+"&help=1");
348 }
349 if(mode == 1)
350 {
351 if(message == "Browse")
352 {
353 loop_image = FALSE;
354 browse(id);
355 return;
356 }
357 if(message == "Next")
358 {
359 extendtimer();
360 next();
361 browse(id);
362 }
363 if(message == "Back")
364 {
365 extendtimer();
366 current_texture--;
368 if(check == 0)
369 {
370 llSetTexture(BLANK,DISPLAY_ON_SIDE);
371 current_texture = 0;
372 report("No pictures found.");
373 return;
374 }
375 if(current_texture < 0)
376 current_texture = check - 1;
377
378 display_texture(check);
379
380 browse(id);
381 return;
382 }
383 if(message == "Menu")
384 {
385 menu(id);
386 return;
387 }
388 if(message == "Loop")
389 {
390 llSetTimerEvent(PICTURE_ROTATION_TIMER);
391 loop_image = TRUE;
392 llOwnerSay("Picture will change every "+(string)PICTURE_ROTATION_TIMER+" seconds.");
393 return;
394 }
395 if(message == "Unloop")
396 {
397 loop_image = FALSE;
398 llOwnerSay("Picture loop disabled.");
399 return;
400 }
401 }
402 if(mode == 2)
403 {
404 if(channel == REMOTE_CHANNEL)
405 {
406 if(encryption == 0)
407 encryption = (integer)message;
408 llListenRemove(listenRemote);
409 listenRemote = -1;
410 llSay(0,"Remote configured ("+(string)id+")");
411 }
412
413 if(message == "Web Guide")
414 {
415 if(isGroup)
416 {
417 if(!encryption)
418 {
419 llSay(0,"** Error - This FreeView object has been deeded to group. You must use a Remote control to open the Web Guide.");
420 llSay(0,"You can set up the remote control from the Video -> Configuration menu. Please refer to the notecard for further assistance.");
421 return;
422 }
423 tell_remote((string)id+(string)XML_channel+(string )llGetOwner());
424 }
425 else
426 llLoadURL(id, "Come to the Guide to Start Your Viewer Playing!", "http://slguide.com/index.php?v=" + (string)llGetKey() + "&c=" + (string)XML_channel + "&o=" + (string)llGetOwner() + "&");
427 return;
428 }
429
430 string header = "Video mode"+moviename+": ";
431
432 if(message == "<< Prev")
433 {
434 notecardline--;
435 if(notecardline < 0)
436 notecardline = numberofnotecardlines - 1;
437 tempuser = id;
438 llGetNotecardLine(NOTECARD,notecardline);
439 return;
440 }
441 if(message == "Next >>")
442 {
443 notecardline++;
444 if(notecardline >= numberofnotecardlines)
445 notecardline = 0;
446 tempuser = id;
447 llGetNotecardLine(NOTECARD,notecardline);
448 return;
449 }
450 if(message == "Use")
451 {
452 if(tempurl == "** No URL specified! **")
453 tempurl = "";
454 seturl(tempurl,id);
455 return;
456 }
457
458 if(message == "Menu")
459 {
460 menu(id);
461 return;
462 }
463 if(message == "Configure")
464 {
465 config(id);
466 return;
467 }
468 if(message == "Bookmarks")
469 {
470 if(notecardcheck != -1)
471 {
472 llDialog(id,"Error: No valid bookmark data found in notecard '"+NOTECARD+"'.",["Menu"],chan);
473 return;
474 }
475 if(finditem(NOTECARD) != -1)
476 {
477 tempuser = id;
478 if(numberofnotecardlines < notecardline)
479 notecardline = 0;
480 llGetNotecardLine(NOTECARD,notecardline);
481 }
482 else
483 llDialog(id,"Error: No notecard named "+NOTECARD+" found in contents.",["Menu"],chan);
484 return;
485 }
486
487 if(llGetLandOwnerAt(llGetPos()) != llGetOwner()) //If we do not have permissions to actually do the following functions
488 {
489 llSay(0,"Error: Cannot modify parcel media settings. "+llGetObjectName()+" is not owned by parcel owner.");
490 menu(id);
491 return; //Abort
492 }
493
494 if(listenUrl != -1 && channel == 1) //Incoming data from "Set URL" command (user spoke on channel 1)
495 {
496 llListenRemove(listenUrl);
497 listenUrl = -1;
498 seturl(message,id);
499 }
500 if(message == "Play")
501 {
502 report(header+"Playing");
504 return;
505 }
506 if(message == "Stop")
507 {
508 report(header+"Stopped");
510 return;
511 }
512 if(message == "Pause")
513 {
514 report(header+"Paused");
515 llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PAUSE" title="View Definition" class="tooltip">PARCEL_MEDIA_COMMAND_PAUSE]);
516 return;
517 }
518 if(message == "Unload")
519 {
520 report(header+"Stopped");
522 return;
523 }
524 if(message == "Loop")
525 {
526 llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_LOOP]);
527 return;
528 }
529 //URL , Auto-Scale,
530 if(message == "Set URL")
531 {
532 report(header+"Stopped");
533 listenUrl = llListen(1,"",id,"");
534 llDialog(id,"Please type the URL of your choice with /1 in thebegining. For example, /1 www.google.com",["Ok"],938);
535 return;
536 }
537 if(message == "Align ON")
538 {
539 report(header+"Stopped");
541 menu(id);
542 return;
543 }
544 if(message == "Align OFF")
545 {
546 report(header+"Stopped");
548 menu(id);
549 return;
550 }
551 if(message == "Set Remote")
552 {
553 llSay(0,"Configuring remote...");
554 encryption = 0;
555 llListenRemove(listenRemote);
556 listenRemote = llListen(REMOTE_CHANNEL,"","","");
557 llSay(REMOTE_CHANNEL,"SETUP");
558 }
559 }
560 }
561
562 dataserver(key queryid, string data)
563 {
564 if(queryid == groupcheck) //Test if object is deeded to group
565 {
566 groupcheck = NULL_KEY;
567 isGroup = FALSE;
568 return;
569 }
570
571 if(queryid == tempuser) //If just checking number of notecard lines
572 {
573 numberofnotecardlines = (integer)data;
574 notecardkey = llGetInventoryKey(NOTECARD);
575 notecardcheck = 0;
576 llGetNotecardLine(NOTECARD,notecardcheck);
577 return;
578 }
579 if(notecardcheck != -1)
580 {
581 if(data != EOF)
582 {
583 if(data == "")
584 {
585 notecardcheck++;
586 llGetNotecardLine(NOTECARD,notecardcheck);
587 }
588 else
589 {
590 notecardcheck = -1;
591 return;
592 }
593 }
594 else
595 return;
596 }
597
598 if(data == "" && notecardline < numberofnotecardlines) //If user just pressed "enter" in bookmarks, skip
599 {
600 notecardline++;
601 llGetNotecardLine(NOTECARD,notecardline);
602 return;
603 }
604
605 if(data == EOF)
606 {
607 notecardline = 0;
608 llGetNotecardLine(NOTECARD,notecardline);
609 return;
610 }
611 list parsed = llParseString2List(data,["|","| "," |"," | "],[]); //Ensure no blank spaces before "http://".
612 string name = llList2String(parsed,0);
613 tempurl = llList2String(parsed,1);
614 if(tempurl == "")
615 tempurl = "** No URL specified! **";
616
617 tempmoviename = name;
618
619 llDialog(tempuser,"Bookmarks notecard ("+(string)(notecardline+1)+"/"+(string)numberofnotecardlines+")\n"+name+" ("+mediatype(llList2String(llParseString2List(tempurl,["."],[]),-1))+")\n"+tempurl,["<< Prev","Use","Next >>","Menu"],chan);
620 }
621
622 remote_data(integer type, key channel, key message_id, string sender, integer ival, string sval)
623 {
624 if(type == REMOTE_DATA_CHANNEL)
625 {
626 XML_channel = channel;
627 }
629 {
630 list media_info = llParseString2List(sval, ["|"], []);
631 tempmoviename = llList2String(media_info,0);
632 seturl(llList2String(media_info,1),NULL_KEY);
633 llRemoteDataReply(channel, message_id, sval, 1);
634 }
635 }
636
637 timer()
638 {
639 if(llGetTime() > listenTimer) //If listener time expired...
640 {
641 llListenRemove(listenHandle); //Remove listeneres.
642 llListenRemove(listenUrl);
643 llListenRemove(listenRemote);
644 listenHandle = -1;
645 listenUrl = -1;
646 listenRemote = -1;
647 listenTimer = -1;
648 if(loop_image == FALSE || mode != 1) //If we're not looping pictures or are in picture mode at all
649 llSetTimerEvent(0.0); //Remove timer
650 }
651
652 if(loop_image == TRUE && mode == 1) //If we're looping pictures and and we're in picture mode...
653 next(); //Next picture
654 }
655 }

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