YouTube Video Player

Thread Started By ☠ MosDef ☠

2605
0
  • 37 Vote(s) - 2.73 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rate Thread
#1
Code:
/*
Anonymous presents...
YouTube Video Player
Tags: scripts, chat, communications, media, movement, light, owner, parcel, primitive, texture, touch, video, featured
Description:
License:
None
http://secondlife.coolminds.org
*/

//send request to web server, get back a url
//set texture
//set parcel media url

string vidurl;
string vidid;
string homeurl;
key mediatexture = "d41f6ea7-e3d3-a8bf-d809-f7cfb52e4757";
string instructions = "Say YouTube links in chat to have them play.";
key httpid;

string VidID(string link)
{
    integer index = llSubStringIndex(link, "v=");
    return llGetSubString(link, index + 2, index + 12);
}

default
{
    touch_start(integer num)
    {
        llSay(0, instructions);
    }
    
    state_entry()
    {
        llSetPrimitiveParams([PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_NONE, PRIM_COLOR, ALL_SIDES, <1,1,1>, 1.0, PRIM_MATERIAL, PRIM_MATERIAL_PLASTIC, PRIM_FULLBRIGHT, ALL_SIDES, 1, PRIM_TEXTURE, ALL_SIDES, NULL_KEY, llGetTextureScale(2), llGetTextureOffset(2), llGetTextureRot(2)]);
        llSetTexture(mediatexture, ALL_SIDES);        
        if (llGetOwner() == llGetLandOwnerAt(llGetPos()))
        {
            llListen(0, "", NULL_KEY, "");
            llListen(1, "", NULL_KEY, "");
            llSay(0, instructions);
        }
        else
        {
            llSay(0, "Error: I am not owned by the landowner.  If the land is group owned, I need to be deeded to group.");
        }

    }
    
    on_rez(integer param)
    {
        llResetScript();
    }
    
    changed(integer change)
    {        
        if (change & CHANGED_OWNER)
        {
            llResetScript();
        }
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if (~llSubStringIndex(message, "http://www.youtube") || ~llSubStringIndex(message, "http://youtube")||~llSubStringIndex(message, "https://www.youtube") || ~llSubStringIndex(message, "https://youtube"))
        {
            list params;
            string vidid;
            //turn the data into a vidid
            vidid = VidID(message);
            //llOwnerSay(vidid);
            string hd;
            if (channel == 1) hd = ".mp4?fs=1";
            else hd = ".mp4";
            homeurl = "http://www.youtubemp4.com/video/" + vidid + hd;
            params = [PARCEL_MEDIA_COMMAND_URL, homeurl];
            params += [PARCEL_MEDIA_COMMAND_TYPE, "video/mp4"];
            llParcelMediaCommandList(params);
            llSay(0, "Playing " + message + ".  Push play on your viewer.");          
        }
    }
}
[Image: 8cWHDmW.png]
Reply




Forum Jump:

1 Guest(s)
Share this:

About Second Life Copybot

Second Life CopyBot Forum is a place where you can get items for Second Life and other vitual worlds for free. With our CopyBot viewers you can export and import any content from these virtual worlds and modify them in 3D software such as Blender, 3D studio Macx etc...