Jump to content

Detect Streaming Music Feed And Change a Prim Color


Ghostwitness
 Share

You are about to reply to a thread that has been inactive for 3710 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

All fixed up thanks to Freya!

Here's the working script if anyone is interested. I'll be cleaning it up a bit for my version and making a few cosmetic changes, but it works :)

// leave music_url blank if set in object's descriptionstring music_url = "http://66.7.214.7:8064"; key HTTPRequest;string feed;string URL;string currSongTitle;string lastSongTitle;list feedList;default{    state_entry()    {        llSetText(" ",<1,1,1>,1);        llSetTimerEvent(5.0);            if(music_url)         {            URL = music_url;        } else {            URL = llGetObjectDesc();        }    }    timer()    {        HTTPRequest=llHTTPRequest(URL + "/7.html HTTP/1.0\nUser-Agent: LSL Script (Mozilla Compatible)\n\n",[],"");    }http_response(key k,integer status, list meta, string body)    {    //llOwnerSay((string)status + " : " + llGetSubString(body,63 + 3, 63 + 3));        if(status != 200)        {            llSetColor(<0.067, 0.067, 0.067>, ALL_SIDES);             llSetText("",<0,0,0>,0);            //REMOVED 'return;'        }        else        {            if(llGetSubString(body,63 + 3,63 + 3) == "0")            {                lastSongTitle = "-1";                currSongTitle = "-2";                llSetColor(<0.067, 0.067, 0.067>, ALL_SIDES);                 llSetText("",<0,0,0>,0);            }            else            {               feed = llGetSubString(body,llSubStringIndex(body, "<body>") + llStringLength("<body>"), llSubStringIndex(body,"</body>") - 1);                feedList = llParseString2List(feed,[","],[]);                currSongTitle = llList2String(feedList,6);                integer length = llGetListLength(feedList);                        if(llList2String(feedList,7))                {                    integer a = 7;                    for(; a<length; ++a)                    {                        currSongTitle += ", " + llList2String(feedList,a);                    }                }                         if (currSongTitle != lastSongTitle)                {                    llSetText(currSongTitle,<1,1,1>,0.75);                    llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);                     lastSongTitle = currSongTitle;                }            }       }  //LINE ADDED    }}

 

Link to comment
Share on other sites


Nova Convair wrote:

This is never TRUE
if(k != HTTPRequest) 

You have only one request, so why would "k" ever be not "HTTPrequest"

 

I have this late arriving tiny bit of clarification:

The http_response event should check that it is dealing with it's own requested response.  Per the WIKI "This events will be triggered in every script in the prim, not just in the requesting script."   In a single script situation it's not "needed" but having it there avoids problems down the line.  For example - later adding a profile photo script to the prim that shows the stream status.

Link to comment
Share on other sites


Ghostwitness wrote:

I'm trying to do something really simple. I want to check to see if my music feed is active and if it is, set the prim color to white. If the feed is not active, set it to black. This would need to check every say 5 minutes or something. What I'm doing is a belt buckle with an ON AIR sign on it that lights up when I am on. I borrowed this code from another tread and thought I understood it enough, but it doesn't see to do anything when the feed is off. Perhaps this script is overkill, I dunno, not a big scripter.

Any help would be appreciated
:)

 
... pirated script from http://www.sluniverse.com/php/vb/756628-post8.html snipped ...

 

For future reference- do NOT post scripts you have found elsewhere on the internet into this forum, it violates both copyright laws and the ToS 2.3 (2nd paragraph) which may result in having your account banned.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3710 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...