Talk:How To Show Video in SL
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
Alternate code
I believe the below is a cleaner way to code the example shown by Vinhold, but his script is shorter and easier to understand by some. Cron Stardust 10:23, 27 September 2007 (PDT)
Code: Basic Video Display Script |
// This script would be used in the prim that will show the video on surface zero. // Touching the prim will start or stop the video display set in Land Media: Video. // Global Variable declarations key DefTexture; vector DefColor; list data; key texture; default { state_entry() { DefTexture = llGetTexture(0); // Save default texture set on prim surface zero. DefColor = llGetColor(0); // Save default color of prim surface zero state stopped; // Setup done, move to stopped state. } } state stopped { state_entry() { llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP]); // Stop streaming to the device. llSetPrimitiveParams([PRIM_TEXTURE,0,DefTexture,<1,1,0>,ZERO_VECTOR,0.0,PRIM_COLOR,0,DefColor,1.0,PRIM_FULLBRIGHT,0,TRUE]); } touch_start(integer total_number) { // Read land parcel media settings data = llParcelMediaQuery([PARCEL_MEDIA_COMMAND_TEXTURE, PARCEL_MEDIA_COMMAND_URL]); if (llList2String(data, 0) == "") { // Not a landowner or land group member error display key ErrTexture = llGetInventoryKey("ErrMsg"); // Get texture by name from inventory llSetPrimitiveParams([PRIM_TEXTURE,0,ErrTexture,<1,1,0>,ZERO_VECTOR,0.0,PRIM_COLOR,0,<1,1,1>,1.0,PRIM_FULLBRIGHT,0,TRUE]); } else { // Ready to start playing state playing; } } } state playing { state_entry() { data = llParcelMediaQuery([PARCEL_MEDIA_COMMAND_TEXTURE, PARCEL_MEDIA_COMMAND_URL]); texture = (key) llList2String(data, 0); // Get texture for parcel to display llSetPrimitiveParams([PRIM_TEXTURE,0,texture,<1,1,0>,ZERO_VECTOR,0.0,PRIM_COLOR,0,<1,1,1>,1.0,PRIM_FULLBRIGHT,0,TRUE]); llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PLAY]); // Start media playing to this device } touch_start(integer total_number) { state stopped; } } |