Advertisement
salahzar

Video chooser for punk

Jun 18th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // remember to have the prim sized something like 16:9  on x and z
  2. // set texture to full bright
  3. // right click the object and touch
  4. // choose the abbreviation
  5. // to insert videos in the video list just get the magic number from the youtube url
  6. // for instance if you have a video like https://www.youtube.com/watch?v=qGhN4g2YjN4 the magic number is what is at the right of v=.
  7.  
  8.  
  9.  
  10.  
  11. list videos = [
  12.     "video1", "xk5uloijNxs",
  13.     "video2", "qGhN4g2YjN4"
  14. ];
  15.  
  16. integer listen_handle;
  17.  
  18. integer LINKED=0;
  19. integer FACE =1 ;
  20.  
  21. string URL;
  22. integer CHANNEL = 1;
  23.  
  24. playURL() {
  25.     llSay(0,"Playing "+URL);
  26.    
  27.     llClearLinkMedia(LINKED,FACE);
  28.     llSetLinkMedia(LINKED,FACE,
  29.                             [PRIM_MEDIA_CURRENT_URL,
  30.                             URL,
  31.                             PRIM_MEDIA_AUTO_SCALE,
  32.                             TRUE,
  33.                             PRIM_MEDIA_AUTO_PLAY,
  34.                             TRUE,
  35.                             PRIM_MEDIA_AUTO_ZOOM,
  36.                             TRUE,
  37.                             PRIM_MEDIA_PERMS_CONTROL,
  38.                             PRIM_MEDIA_PERM_NONE,
  39.                             PRIM_MEDIA_WIDTH_PIXELS, 0,
  40.                             PRIM_MEDIA_HEIGHT_PIXELS, 0,
  41.                             PRIM_MEDIA_FIRST_CLICK_INTERACT, 1,
  42.                             PRIM_MEDIA_PERMS_INTERACT, 4,
  43.                             PRIM_MEDIA_PERMS_CONTROL, 4]);
  44. }
  45.  
  46. stop(){
  47.     llClearLinkMedia(LINKED,FACE);
  48. }
  49.  
  50.  
  51. default
  52. {
  53.     state_entry()
  54.     {  
  55.         listen_handle = llListen(CHANNEL, "", NULL_KEY, "");
  56.        
  57.     }
  58.     touch_start(integer count){
  59.         llDialog(llDetectedKey(0),"Scegli video", llList2ListStrided(videos,0,-1,2) + ["go","stop"],CHANNEL);
  60.     }
  61.  
  62.     listen( integer channel, string name, key id, string message )
  63.     {
  64.         llSay(0,"received "+message);
  65.         integer index = llListFindList(videos,[message]);
  66.         llSay(0,"index is "+(string)index);
  67.         if(index>=0){
  68.            
  69.             string youtubeId = llList2String(videos,index+1);
  70.             URL = "http://www.youtube.com/embed/"+youtubeId+"?rel=0&autoplay=1;fs=0;autohide=1;hd=1;";
  71.            
  72.            
  73.         }
  74.         else if(llToLower(message)=="stop"){
  75.             URL = "";
  76.             stop();
  77.             return;
  78.         }
  79.        
  80.        playURL();
  81.     }
  82.    
  83.    
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement