Change font size
It is currently Sat Sep 21, 2019 9:12 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 3 posts ]
Author Message
 Post subject: Video Player
PostPosted: Fri Nov 14, 2014 10:50 am 
Furious Typer

Joined: Mon Apr 22, 2013 11:41 am
Posts: 86
Location: Texas
This uses media-on-prim to play videos from a web URL. I wrote this to make adding new videos simple without a lot of script editing.

The script generates a menu from notecards stored in the object. For example, to have a menu item in the player for cat videos, I create a notecard in the object named "Cats". The notecard has the format
{L_CODE}:
1stVideo
http://www.webserver.com/one.mp4
2ndVideo
http://www.webserver.com/two.mp4


When I click on the viewer the menu gives me a button labeled "Cats". Clicking that button will give me a new menu with buttons named "1stVideo" and "2ndVideo". Clicking on those buttons will start the vid.

To add new categories, I just add a new notecard, one for each category. There is also an "Off" button, which returns the player to a default texture.

The script:
{L_CODE}:
integer channel_dialog;
list buttons = ["Off"];
key ToucherID;
string message;
integer listenID;
string category;

get_categories()
{
    integer n = 0;
    while (llGetInventoryName(INVENTORY_NOTECARD,n) != "")
    {
        buttons = buttons + llGetInventoryName(INVENTORY_NOTECARD,n);
        ++n;
    }
}

get_videoList(string category)
{
    integer NumLines = osGetNumberOfNotecardLines(category);
    integer n;
    for(n=0;n<NumLines;n=n+2)
    {
        string NoteCardLine = osGetNotecardLine(category,n);
        if (NoteCardLine != "")
        {
            buttons = buttons + NoteCardLine;
        }
    }
}

play_video(string vid_url)
{
    llSetPrimMediaParams(2,
        [
            PRIM_MEDIA_ALT_IMAGE_ENABLE, 1,
            PRIM_MEDIA_CURRENT_URL, vid_url,
            PRIM_MEDIA_AUTO_LOOP, 1,
            PRIM_MEDIA_AUTO_PLAY, 1,
            PRIM_MEDIA_AUTO_SCALE, 1,
            PRIM_MEDIA_PERMS_CONTROL, PRIM_MEDIA_PERM_NONE
        ]);
}

string get_video(string title)
{
    integer NumLines = osGetNumberOfNotecardLines(category);
    integer n;
    for(n=0;n<NumLines;++n)
    {
        string NoteCardLine = osGetNotecardLine(category,n);
        if (NoteCardLine == title)
        {
            NoteCardLine = osGetNotecardLine(category,n+1);
            return NoteCardLine;
        }
    }
    return "";
}

default
{
    state_entry()
        {
        llClearPrimMedia(2);
        channel_dialog = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
        state main_menu;
        }
}

state main_menu
{
    state_entry()
    {
        buttons = ["Off"];
        message = "\nChoose a category.";
        get_categories();
    }
         
        touch_start(integer num_detected)
        {
            ToucherID = llDetectedKey(0);
            llDialog(ToucherID, message, buttons, channel_dialog);
            listenID = llListen(channel_dialog, "", ToucherID, "");
        }

        listen(integer channel, string name, key id, string message)
        {
            if (message == "Off")
            {
                state default;
            }
            else
            {
                category = message;
                state sub_menu;
            }
        }
}

state sub_menu
{
    state_entry()
    {
        buttons = ["Off"];
        message = "\nChoose a video.";
        get_videoList(category);
        llDialog(ToucherID, message, buttons, channel_dialog);
        listenID = llListen(channel_dialog, "", ToucherID, "");
    }

    listen(integer channel, string name, key id, string message)
    {
        if (message == "Off")
        {
            state default;
        }
        else
        {
            play_video(get_video(message));
        }
        state main_menu;
    }
}


Top
 Profile  
 
 Post subject: Re: Video Player
PostPosted: Sun Nov 23, 2014 1:43 pm 

Joined: Thu Sep 11, 2014 8:51 pm
Posts: 13
Great just what I was looking for. I used to stream from YouTube... I guess that went away, and most streamers are using https which don't seem to work with opensim.

What is best way to stream from a service, preferably free, and not your PC?

thanks

tony


Top
 Profile  
 
 Post subject: Re: Video Player
PostPosted: Sun Nov 23, 2014 3:12 pm 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 444
Try this site, they have thousands of interesting videos which you can play and stream into opensim.

http://archive.org/web/web.php


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 3 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net