Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Dj Mixer / Parcel Music Manager

Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
12-04-2006 22:47
This Will allow you to change stations via a touch and dialog.
It also allows you to have a user list.
This requires two parts one is the mixer the other is a repeter which should be by the mixer (usefull for group lands if its a group land make sure the prim thats the reciever not the mixer is group owned.)
This also contacts my server and grabs the shoutcast info for the station your on and displays it on a hover text on the mixer.


-The Mixer-
Script name: sc
CODE

//Writen By Dimentox Travanti
//Please leave this Intact
//You may not SELL this script.
//You may have limited liscence to use the SC query.
//This script is covered by the Creative Commons Liscence

string stationcard = "Stations";
string userc = "users";
integer cline = 0;
integer tline = 0;
key qstation;
key qlines;
integer d = 3;
string http ="http://";
string col = ":";
string scip;
string scpt;
string stationname;
integer x=0;
integer y=0;
integer z=0;
list users;
integer uline = 0;
key uquery;
key whotouch;
integer handle;
string request;
qsc()
{
request = "http://www.dimentox.com/sc/sc2.php?scip=" + scip + "&scpt=" + scpt;
llHTTPRequest(request,[HTTP_METHOD,"GET"],"");
}
change_s()
{
z = cline + d;
x = 0;
if (x > tline)
{
cline = 0;
}

qstation = llGetNotecardLine(stationcard, cline);

}
default
{
state_entry()
{

llSetText("loading", <1,1,1>, 1.0);
handle = llListen(-12345, "", NULL_KEY, "");
qlines = llGetNumberOfNotecardLines(stationcard);
uquery = llGetNotecardLine(userc, uline);
change_s();
cline = 0;

llSetTimerEvent(30);
}
on_rez(integer blahh)
{
llResetScript();
}
touch_start(integer times)
{
whotouch = llDetectedKey(0);
//string search = llDetectedName(0);
integer index = llListFindList( users, [llDetectedName(0)]);

if ( index != -1)
{
llListenRemove(handle);
handle = llListen(-12345, "", llDetectedKey(0), "");
llDialog(llDetectedKey(0), "Current Station " + stationname , ["Previous" , "Next", "Reset"], -12345);
} else {
llInstantMessage(whotouch, "You are not a DJ you may not change stations");
}
}
listen(integer channel, string name, key id, string message)
{
if (message == "Previous")
{
if (cline >= d)
{
cline = cline - d;
cline = cline - d;
change_s();
} else
{
cline = 0;
change_s();
}
//change_s();
}
if (message == "Next")
{
change_s();
}
if (message == "Reset")
{
llResetScript();
}

}
dataserver(key queryid, string data) {
if (queryid == uquery) {
if (data != EOF) {
users = users + [data];
++uline;
uquery = llGetNotecardLine(userc, uline);
}
}



if (queryid == qlines)
{

tline = (integer)data;

}
if (queryid == qstation) {
if (data != EOF) {
if (x == 0)
{
stationname = data;
if (whotouch){
llInstantMessage(whotouch, "Station Set to " + stationname);
}

}
if (x == 1)
{
//llSay(0, "ip"+data);
scip = data;
}
if (x == 2)
{
// llSay(0, "port"+data);
scpt = data;
}

++cline;
++x;
if (cline < z ){
qstation = llGetNotecardLine(stationcard, cline);
} else {
string media = "http://" + scip + ":" + scpt + "/";
qsc();
//this is for the group land with a reciever(might want to change the chan)
llWhisper(123456, "music " + media);
//uncomment this for a single prim on not grp based land
//llSetParcelMusicURL(media);
}




}
}


}
timer()
{
llSetText("loading", <1,1,1>, 1.0);
//llHTTPRequest("http://www.dimentox.com/sc/sc.php",[HTTP_METHOD,"GET"],"");
qsc();

}
http_response(key id, integer status, list metadata, string body)
{
llSetText("Station: " + stationname + "\n" + body, <1,1,1>, 1.0);
}

}


Note cards for the Mixer

Notecard:Stations
line 1: Name
line2: url w/o http
line3: port
Has to be this way for the hover text query.
CODE

Lost Angel's Radio
stream.dimentox.com
8000
UltraDark #1
84.16.231.180
3026
UltraDark #2
85.214.63.31
3026
Doomed
somafm-sc.streamguys.com
8300
Temple SL
66.197.50.71
8130


Notecard: users
full name per line
CODE

Dimentox Travanti
Ashes Arizona



-----Reciever---
aka for grp lands or non grp lands
this changes the actual media on the land

(you might want a transparent textoure on this prim)
script: Media Controller
CODE

//Writen By Dimentox Travanti
//Please leave this Intact
//You may not SELL this script.
//You may have limited liscence to use the SC query.
//This script is covered by the Creative Commons Liscence
default
{
state_entry()
{
llListen(123456, "", NULL_KEY, "");
}

listen( integer channel, string name, key id, string message )
{
if (llGetSubString(message, 0,4) == "music")
{
string media = llGetSubString(message, 6, -1);
llSetParcelMusicURL(media);
}
}

}


You might wanna change the channels for the reciever and dialogs.
_____________________
LSL Scripting Database - http://lsl.dimentox.com
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-05-2006 01:54
I have soemthing similar where the primary object, the mixer, rez's the receiver passing it a randomised channel number for comms. Save the channel number into the description then it will still be there when the receiver is set to group.
FireEyes Fauna
Registered User
Join date: 26 Apr 2004
Posts: 138
12-06-2006 14:25
Just curious if there's a way to get a stream in the format of
to properly work with this script.
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
12-06-2006 19:28
From: FireEyes Fauna
Just curious if there's a way to get a stream in the format of
to properly work with this script.

I'm wondering this too. The radio script I'm currently using (available here) can work with those URLs so all I really need is a way for the stream info retrieval function from this script to properly deal with them. I'm guessing that could only be fixed server side though.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-07-2006 00:22
From: Talon Brown
I'm wondering this too. The radio script I'm currently using (available here) can work with those URLs so all I really need is a way for the stream info retrieval function from this script to properly deal with them. I'm guessing that could only be fixed server side though.

I think so. Dimentox gave the notecard format as
CODE

line 1: Name
line2: url w/o http
line3: port


SO I would guess that it should be
CODE

My Radio Station
64.236.34.97
80/stream/1010
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
12-07-2006 05:31
that should work.
The reason the notecard was parsed that was is so the Stats server will grab the right info.
but that should work bnut it would break the scast
the other ay to do it is add one to the var d and add a new notecard line and add a parser for it
i will prob be doing that.


ill repost a new version
_____________________
LSL Scripting Database - http://lsl.dimentox.com
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
12-07-2006 15:05
My issue wasn't with the script itself, it was with the web script that's being contacted to get the stream data. It works with ordinary stream URLs but if you pass it a port like "80/stream/1040" it returns HTML encoded text saying "Server is: offline." So I wondered if it was possible for it to work with those more complex port strings since just stripping the text after the port value doesn't return any usable data either.
FireEyes Fauna
Registered User
Join date: 26 Apr 2004
Posts: 138
12-07-2006 17:21
Right, my request was for being able to retrieve the stream information of the url type I provided.
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
12-10-2006 18:30
Weird. Now my radio script is always receiving the "Server is offline" reply from the stat server even though my friend in an adjacent sim is using the exact same script and it's still working for her. Anyone have any idea how that is possible?

Update: And now it's working again in my sim after not doing so since yesterday. Vexing.