Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Parcel DJ Station / Media changer

Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
12-04-2006 22:46
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
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
12-05-2006 08:24
/54/87/152921/1.html
_____________________
i've got nothing. ;)
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
12-05-2006 23:23
I'm right in assuming the stream data returned is only valid with simple domain : port URLs? Doesn't seem to handle more complex stream URLs such as http://64.236.34.97:80/stream/1040 properly at all. Other than that, nice work. :)
Glory Takashi
You up for a DNA test?
Join date: 26 Feb 2006
Posts: 182
12-13-2006 15:07
This is great now if you can make a version that does not contact your server for info I would love it.
_____________________
I speak my mind and make no appologies for my opinion.
Dimentox Travanti
DCS Coder
Join date: 10 Sep 2006
Posts: 228
12-18-2006 10:24
The sc2 script is a modified script i found...
but here it is.


FILE: sc2.php
CODE

?php
//header("Content-type: text/plain; charset=UTF-8");

//_____________________________________________________________________________
//=============================================================================
//
// SCSTATS v1.1 - Shoutcast Stats Quirier
// Orginal DL Location: http://public.ravetrax.com/scripts/scstats/
//
// This php application will quiry one shoutcast server, and then display the
// output as desired by the user altered templates.
//
// Copyright (C) 2005 - RaveTrax / Eric Crispen [aka: Rava]
//
// To contact me send email to: rava@ravetrax.com / eric@crispen.com
// Modified by Dimentox Travanti - for SL..
// you must have register globals on or you need to change the code to use the post vars
//-----------------------------------------------------------------------------
//
// The following are usable variables in the output templates:
//
// $listener_c = Current Listener Count
// $listener_p = Listener Peak Count
// $listener_m = Listener Max Count
// $listener_r = Report Listener Count
// $sc_bitrate = Current Stream Bitrate
// $sc_playing = Current Title Playing
//
//-----------------------------------------------------------------------------
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation; either version 2 of the License, or any later version.
//
// This program is distributed in hopes that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. Remeber, you are responible for your
// own actions, and at any time you may not blame me for anything that this
// script might have done.
//
// For more info on the GNU General Public License related to this program,
// write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
//=============================================================================
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//-----------------------------------------------------------------------------
//--[ put the path to your config file below

$cfg_path = "_scstats.cfg";

//--[ script stats function
function quiry_scserv($scservurl, $scservprt) {
//--[ kets turn all host names to ips
$scservfip = gethostbyname($scservurl);
//--[ lets open a socket to the shoutcast server
$getscserv = fsockopen($scservfip, $scservprt, &$errno, &$errstr, 10) or $php_err .= "server doa";
//--[ clear any leftover data
$servquiry = "";
//--[ if server is not found, return server quiry as offline
if (!$getscserv) { return "offline"; }
//--[ if server is online, go further
else {
//--[ ok we are in! lets quiry shoutcasts public 7.html page
fputs($getscserv, "GET /7.html HTTP/1.1\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: RaveTrax SC_Serv Stats Getter v1.1 (Mozilla Compatible)\r\nConnection: Keep-Alive\r\n\r\n");
//--[ keep reading until we reach the end of the file
while (!feof($getscserv)) { $servquiry .= fread($getscserv, 500); }
//--[ close socket once we are done reading the 7.html file
fclose($getscserv);
//--[ lets read and setup the string... call the cows, a haystack is nearby
$quiryb = substr($servquiry, strpos($servquiry, "\r\n\r\n") + 4);
//--[ ok fucntion complete, lets return our server quiry as online with data
return $quiryb;
}
}
//--[ verifies you set a config file path, continues or exits...
if (!$cfg_path) { echo "no config file listed!"; exit; }
else { include($cfg_path); $cfg_key = str_replace("ravetrax" ,"y", $cfg_key); }
//--[ the next few lines just varify that you have read the read me and edited the config
//--[ file as needed, then continues or exits as needed... i'm so evil... :)
if (!$html_a) { echo "no offline template found in config file"; exit; }
if (!$html_b) { echo "no online template found in config file"; exit; }
if ($cfg_key != "y") { echo "config file not found or formatted incorrectly!"; exit; }
else {
//--[ this is the guts of the script, lets call function here, hide if it fails
//echo "<!-- ";
$scserv_quiry = quiry_scserv($scip, $scpt);
//echo " -->";
//--[ returned quiry is offline, lets bail!
if ($scserv_quiry == "offline") {
//--[ what verbage should be used?
$csc_status = "$lang_a";
//--[ lets get the offline template and show user what we found.
include($html_a);
//--[ time to exit... see ya!
exit; }
//--[ retuned quiry is online! let continue here
else {
//--[ lets explode the quiry data into an array...
$quirydat = explode(",", $scserv_quiry);
//--[ ok, now lets double check to see if server is actually broadcasting
if ($quirydat[1] == "1") {
//--[ double check says server is online, lets continue here.
//--[ what verbage should be used?
$csc_status = "$lang_b";
//--[ now lets turn the pretty array into some variables for output.
$listener_c = $quirydat[0]; $listener_p = $quirydat[2];
$listener_c = strip_tags($listener_c);

$listener_m = $quirydat[3]; $listener_r = $quirydat[4];
$listener_m = strip_tags($listener_m);

$sc_bitrate = $quirydat[5];
$sc_playing = $quirydat[6];
$sc_playing = strip_tags($sc_playing);

//--[ let get the online template and show user the stats what we found.
include($html_b);
}
else {
//--[ double check says server is offline, lets bail!
//--[ what verbage should be used?
$csc_status = "$lang_a";
//--[ let get the offline template and show user what we found.
include($html_a);
//--[ time to exit... see ya!
exit;
}
}
}

//_____________________________________________________________________________
//=============================================================================
//--[ ok stop reading now, time to say goodbye! developed by rava@ravetrax.com
?>



Heres the config file
File: _scstats.cfg
CODE

//--[ shoutcast server ip and port
//moded and depricated for SL script
// $scip = "www.ravetrax.com";
// $scpt = "8128";


//-----------------------------------------------------------------------------
//--[ html outplut template files

$html_a = "_html-offline.sub";
$html_b = "_html-online.sub";


//-----------------------------------------------------------------------------
//--[ hard coded words - change to fit your needs

$lang_a = "Offline";
$lang_b = "Online";


//-----------------------------------------------------------------------------
//--[ this little trap must be set to "ravetrax" before the script will work

$cfg_key = "ravetrax";

//_____________________________________________________________________________
//=============================================================================
//--[ config is complete, time to say goodbye! developed by rava@ravetrax.com
?>



heres the html

file: _html-online.sub
CODE

Playing: <? echo $sc_playing; ?>
------------------------------------------
Current Listeners: <? echo $listener_c; ?>
Listener Peak: <? echo $listener_p; ?>
Max Listeners: <? echo $listener_m; ?>
Bitrate: <? echo $sc_bitrate; ?>


file: _html-offline.sub
CODE

Server Is Currently: <? echo $csc_status; ?>
_____________________
LSL Scripting Database - http://lsl.dimentox.com
Tasman Perth
Geekette Extraordinaire
Join date: 7 Jun 2005
Posts: 225
01-20-2008 08:19
I use this script in my club... but recently, I noticed that the area of the floating text which normally shows the title-artist of the current song is now saying "please don't use this server anymore for shoutcast streams".. Thinking that I was seeing this from SkyFM, I checked the urls and found they were fine.. A bit more checking and I find this is coming from Dimentox's sc website.. I modded the script to not hit his website anymore, as the script works great otherwise.
I'm commenting here to see if theres a diff url to put in the script, as I LOVE the song-artist display of this program....

Tas