Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Setting Media Texture & Media Autoscale Automatically

Funkfenomenon Felisimo
Armchair Entrepreneur
Join date: 15 Sep 2007
Posts: 50
03-02-2008 10:40
I'm sincerely sorry if the solution has been posted here before but afer an hour of scanning posts and performing searches I'm not finding aything.

I've invested in about 3,000 scripts over the last week or so and have learned a LOT but seemingly not yet enough.

I know that FreeView has this functionality, but the autoscale is done through a menu button.

I've written a very slick video player script that I'm very proud of. It does everything I want except one specific thing (well, two actually) - setting the media texture and autoscale function AUTOMATICALLY.

Presently I have to go in and manually set the texture and put a check on autoscale before I can enjoy my media player.

I don't want to have to select anything as an option, and don't want any added buttons. When I click on my video screen presently it brings up a menu for selecting what movie to watch. What I'd like is some kind of automated "onclick" code that will automatically set the media texture and set autoscale to yes without any user intervention.

Is this possible? A code sample would be greatly appreciated!

- Funk
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
03-02-2008 12:24
I think this may do what you want, but I'm on Linux and haven't had much opportunity to mess with video, so good luck!

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llParcelMediaCommandList
Funkfenomenon Felisimo
Armchair Entrepreneur
Join date: 15 Sep 2007
Posts: 50
03-02-2008 13:23
Thanks Hewee for the link...

I've come up with this so far...

The following script, when applied to a prim will automatically begin playing a video when you click the prim.

Currently it automatically sets the texture and automatically aligns the video stream so it takes up the entire face of the prim.

Now, what I'm having trouble figuring out is how to do one thing:

1. Set the actual texture (currently it plays the video on the default wood texture. I'm not sure how to set the asset ID for a specific texture I want to use). I know how to get the asset id but not where to put it in this code so it knows what specific texture to set in the Media Tab in About Land.

Thanks!!!

- Funk





float START_TIME = 30.0;
float RUN_LENGTH = 10.0;

default
{
state_entry()
{
if ( llParcelMediaQuery([PARCEL_MEDIA_COMMAND_TEXTURE]) == [] )
llSay(0, "Lacking permission to set/query parcel media. This object has to be owned by/deeded to the land owner.";);
llParcelMediaCommandList( [
PARCEL_MEDIA_COMMAND_URL, "http://eric.stamen.com/mov/doa101.mov",
PARCEL_MEDIA_COMMAND_TEXTURE, (key) llGetTexture(0) ] );
}

touch_start(integer num_detected)
{
llParcelMediaCommandList( [
PARCEL_MEDIA_COMMAND_AGENT, llDetectedKey(0),
PARCEL_MEDIA_COMMAND_TIME, START_TIME,
PARCEL_MEDIA_COMMAND_AUTO_ALIGN, TRUE,
PARCEL_MEDIA_COMMAND_PLAY ] );
list Info = llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL, PARCEL_MEDIA_COMMAND_TEXTURE]);
llSay(0, "Playing '" + llList2String(Info, 0) + "' on texture '" + (string)llList2Key(Info, 1) + "' for agent " + llDetectedName(0));
llSetTimerEvent(RUN_LENGTH);
}

timer()
{
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_STOP ] );
llSetTimerEvent(0.0);
}
}
Funkfenomenon Felisimo
Armchair Entrepreneur
Join date: 15 Sep 2007
Posts: 50
03-02-2008 13:31
BTW, I know it has to do with PARCEL_MEDIA_COMMAND_TEXTURE but this is what the Wiki says:

"specifies the texture to replace with video Note: If passing the key of a texture, it must be explicitly typecast as a key, not just passed within double quotes."

Not sure what it meant to "explicitly typecast as a key" - I'm still fairly new to scripting so some terminology is a bit confusing for me.

- Funk
Funkfenomenon Felisimo
Armchair Entrepreneur
Join date: 15 Sep 2007
Posts: 50
I Figured It Out...
03-02-2008 13:48
Yay, perseverance...

I figured it out after doublechecking and rummaging through the FreeView code...

This is the final script that will display the video on the texture of my choice and will auto play, and autoscale automatically.








key VIDEO_DEFAULT = "d7e82d94-aff4-6124-5355-1a8e0ac28457";

default
{
state_entry()
{
if ( llParcelMediaQuery([PARCEL_MEDIA_COMMAND_TEXTURE]) == [] )
llSay(0, "Lacking permission to set/query parcel media. This object has to be owned by/deeded to the land owner.";);
llParcelMediaCommandList( [
PARCEL_MEDIA_COMMAND_URL, "http://eric.stamen.com/mov/doa101.mov",
PARCEL_MEDIA_COMMAND_TEXTURE, (key) llGetTexture(0) ] );
}

touch_start(integer num_detected)
{
llParcelMediaCommandList( [
PARCEL_MEDIA_COMMAND_AGENT, llDetectedKey(0),
PARCEL_MEDIA_COMMAND_TEXTURE, VIDEO_DEFAULT,
PARCEL_MEDIA_COMMAND_AUTO_ALIGN, TRUE,
PARCEL_MEDIA_COMMAND_PLAY ] );
list Info = llParcelMediaQuery([PARCEL_MEDIA_COMMAND_URL, PARCEL_MEDIA_COMMAND_TEXTURE]);
llSay(0, "Playing '" + llList2String(Info, 0) + "' on texture '" + (string)llList2Key(Info, 1) + "' for agent " + llDetectedName(0));
}

timer()
{
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_STOP ] );
llSetTimerEvent(0.0);
}
}