Difference between revisions of "User:Cow Taurog/Radio tuner"
Cow Taurog (talk | contribs) (create page) |
Lady Sumoku (talk | contribs) (Replaced old <LSL> block with <source lang="lsl2">, also for <php>) |
||
Line 1: | Line 1: | ||
These scripts will allow you to change your land's [[Streaming Music|music url]] from a list of presets, or by saying the url of a <span class="plainlinks">[http://en.wikipedia.org/wiki/PLS_(file_format) *.pls playlist file] over chat. Place the fread.php file on a webhost, set the tuner script to use that url, and drop the tuner script into a prim. There is also a relay script for group land. You can copy the url of a playlist file from a webpage, or a 'Tune in' link from <span class="plainlinks">[http://shoutcast.com shoutcast.com]</span> as well. | These scripts will allow you to change your land's [[Streaming Music|music url]] from a list of presets, or by saying the url of a <span class="plainlinks">[http://en.wikipedia.org/wiki/PLS_(file_format) *.pls playlist file] over chat. Place the fread.php file on a webhost, set the tuner script to use that url, and drop the tuner script into a prim. There is also a relay script for group land. You can copy the url of a playlist file from a webpage, or a 'Tune in' link from <span class="plainlinks">[http://shoutcast.com shoutcast.com]</span> as well. | ||
==Tuner== | ==Tuner== | ||
< | <source lang="lsl2"> | ||
string gsBaseURL="http://example.com/fread.php?url="; // Set this to point to your fread.php file | string gsBaseURL="http://example.com/fread.php?url="; // Set this to point to your fread.php file | ||
integer giChan=8437; // This channel is used to communicate with the relay. | integer giChan=8437; // This channel is used to communicate with the relay. | ||
Line 144: | Line 144: | ||
} | } | ||
} | } | ||
</ | </source> | ||
==Group relay== | ==Group relay== | ||
If the land you want to change the music url on is [[Groups and Land|owned by a group]], you need to use this relay script. Place it in a prim, and deed it to the group that owns the land. This script is also useful if you have more than one parcel of land in the same sim, and want to change the music in more than one place at the same time. Make sure the both the script and the prim have full permissions set before deeding so you can sell it back to yourself and make changes if needed. | If the land you want to change the music url on is [[Groups and Land|owned by a group]], you need to use this relay script. Place it in a prim, and deed it to the group that owns the land. This script is also useful if you have more than one parcel of land in the same sim, and want to change the music in more than one place at the same time. Make sure the both the script and the prim have full permissions set before deeding so you can sell it back to yourself and make changes if needed. | ||
< | <source lang="lsl2"> | ||
integer giChan=8437; // replace this with something random, match with the tuner script | integer giChan=8437; // replace this with something random, match with the tuner script | ||
string gsOriginalMusic; | string gsOriginalMusic; | ||
Line 162: | Line 162: | ||
} | } | ||
} | } | ||
</ | </source> | ||
==fread.php== | ==fread.php== | ||
[[llHTTPRequest]] only supports the reading of certain filetypes, and *.pls is not one of them. This script will display any URL fed to it as text. | [[llHTTPRequest]] only supports the reading of certain filetypes, and *.pls is not one of them. This script will display any URL fed to it as text. | ||
<php> | <source lang="php"> | ||
<?php | <?php | ||
$file = $_GET['url']; | $file = $_GET['url']; | ||
Line 176: | Line 176: | ||
print $contents; | print $contents; | ||
?> | ?> | ||
</ | </source> |
Latest revision as of 19:46, 11 April 2015
These scripts will allow you to change your land's music url from a list of presets, or by saying the url of a *.pls playlist file over chat. Place the fread.php file on a webhost, set the tuner script to use that url, and drop the tuner script into a prim. There is also a relay script for group land. You can copy the url of a playlist file from a webpage, or a 'Tune in' link from shoutcast.com as well.
Tuner
string gsBaseURL="http://example.com/fread.php?url="; // Set this to point to your fread.php file
integer giChan=8437; // This channel is used to communicate with the relay.
integer giDialog=8957; // This channel is used for the dialog menu.
float gfResetDelay=20; // This is the number of seconds the script will wait for a response.
integer giPrivateChan=200; // This is a private channel for saying a playlist url.
//These are presets for the dialog menu
list gl1=["DI.fm","Somafm","-None-","XRM Alt","Hot 108","Open PLS"];
list glD1=["Trance","Vocal","ElecHouse","Chillout","EuroDance","House","SoulHouse","FunkHouse","TrblHouse","HardDance","Minimal","2>"];
list glD2=["<1","Techno","Progresve","GoaPsy","Hardstyle","Hardcore","DjMixes","Lounge","Drum&Bass","OldElectr","Ambient","3>"];
list glD3=["<2","Breaks","FutureSyn","Gabber","XRM Alt","-None-"];
list glS1=["Lush","Digi","GrvSalad","DrneZone","SpaceSta","BeatBlnd","IndiePop","Cliqhop","SncVerse","ILstreet","BootLiqr","2>"];
list glS2=["<1","TagsTrip","ScrtAgnt","Doomed"];
// Declarations
key gkDet;
string gsPlaylistURL;
key gkRequest;
integer giIndex1;
integer giIndex2;
string gsStart="File1=";
string gsEnd="Title1=";
integer DEBUG=2; // 0-none, 1-minimal, 2-verbose
default{
state_entry(){
llListen(giDialog,"","","");
llSetTimerEvent(gfResetDelay);
}
timer(){llResetScript();}
on_rez(integer param){llResetScript();}
touch_start(integer num){
//if(llSameGroup(llDetectedKey(num-1))==TRUE){
gkDet=llDetectedKey(num-1);
llDialog(gkDet,"Pick a station...",gl1,giDialog);
//}
}
listen(integer chan,string name,key id,string mess){
if(mess=="DI.fm"){state difm;}
if(mess=="Somafm"){state somafm;}
if(mess=="Open PLS"){state hearpls;}
if(mess=="-None-"){llRegionSay(giChan,"setmusic|");llResetScript();}
if(mess=="XRM Alt"){llRegionSay(giChan,"setmusic|http://72.236.163.63:12929");llResetScript();}
if(mess=="Hot 108"){llRegionSay(giChan,"setmusic|http://scfire-dtc-aa03.stream.aol.com:80/stream/1071");llResetScript();}
}
}
state hearpls{
state_entry(){
llSetTimerEvent(gfResetDelay);
llListen(0,"",gkDet,"");
llListen(giPrivateChan,"",gkDet,"");
llSay(0,"Say the URL of a *.pls file to play over public chat or /"+(string)giPrivateChan+".");
}
timer(){llSay(0,"Timeout.");llResetScript();}
listen(integer chan,string name,key id,string mess){
gsPlaylistURL=mess;
state openpls;
}
}
state openpls{
state_entry(){
gkRequest=llHTTPRequest(gsBaseURL+gsPlaylistURL,[],"");
llSetTimerEvent(gfResetDelay);
}
timer(){llSay(0,"Timeout.");llResetScript();}
http_response(key request,integer status,list meta,string body){if(gkRequest==request){if(status==200){if(body!=""){
giIndex1=(llSubStringIndex(body,gsStart)+llStringLength(gsStart));
giIndex2=(llSubStringIndex(body,gsEnd)-2);
body=llGetSubString(body,giIndex1,giIndex2);
llSetParcelMusicURL(body);
llRegionSay(giChan,"setmusic|"+body);
llResetScript();
}}}}
}
state difm{
state_entry(){
llListen(giDialog,"","","");
llDialog(gkDet,"Pick a station...",glD1,giDialog);
llSetTimerEvent(gfResetDelay);
}
timer(){llResetScript();}
on_rez(integer param){llResetScript();}
listen(integer chan,string name,key id,string mess){
if(mess=="3>"){llDialog(gkDet,"Pick a station...",glD3,giDialog);}
if(mess=="<2"){llDialog(gkDet,"Pick a station...",glD2,giDialog);}
if(mess=="2>"){llDialog(gkDet,"Pick a station...",glD2,giDialog);}
if(mess=="<1"){llDialog(gkDet,"Pick a station...",glD1,giDialog);}
if(mess=="-None-"){llRegionSay(giChan,"setmusic|");llResetScript();}
if(mess=="Trance"){llRegionSay(giChan,"setmusic|http://scfire-ntc-aa01.stream.aol.com:80/stream/1003");llResetScript();}
if(mess=="Vocal"){llRegionSay(giChan,"setmusic|http://scfire-ntc-aa02.stream.aol.com:80/stream/1065");llResetScript();}
if(mess=="ElecHouse"){llRegionSay(giChan,"setmusic|http://scfire-ntc-aa03.stream.aol.com:80/stream/1025");llResetScript();}
if(mess=="Chillout"){llRegionSay(giChan,"setmusic|http://scfire-mtc-aa02.stream.aol.com:80/stream/1035");llResetScript();}
if(mess=="EuroDance"){llRegionSay(giChan,"setmusic|http://scfire-mtc-aa02.stream.aol.com:80/stream/1024");llResetScript();}
if(mess=="House"){llRegionSay(giChan,"setmusic|http://scfire-mtc-aa01.stream.aol.com:80/stream/1007");llResetScript();}
if(mess=="SoulHouse"){llRegionSay(giChan,"setmusic|http://di-fm-01.quintex.com:8880");llResetScript();}
if(mess=="FunkHouse"){llRegionSay(giChan,"setmusic|http://91.121.228.33:8004");llResetScript();}
if(mess=="TrblHouse"){llRegionSay(giChan,"setmusic|http://di-fm-01.quintex.com:8882");llResetScript();}
if(mess=="HardDance"){llRegionSay(giChan,"setmusic|http://209.247.146.98:8000");llResetScript();}
if(mess=="Minimal"){llRegionSay(giChan,"setmusic|http://66.135.35.144:8000");llResetScript();}
if(mess=="Techno"){llRegionSay(giChan,"setmusic|http://208.122.59.30:7204");llResetScript();}
if(mess=="Progresve"){llRegionSay(giChan,"setmusic|http://scfire-ntc-aa04.stream.aol.com:80/stream/1026");llResetScript();}
if(mess=="GoaPsy"){llRegionSay(giChan,"setmusic|http://scfire-ntc-aa01.stream.aol.com:80/stream/1008");llResetScript();}
if(mess=="Hardstyle"){llRegionSay(giChan,"setmusic|http://72.51.40.90:8000");llResetScript();}
if(mess=="Hardcore"){llRegionSay(giChan,"setmusic|http://88.191.69.69:80");llResetScript();}
if(mess=="DjMixes"){llRegionSay(giChan,"setmusic|http://209.247.146.100:8000");llResetScript();}
if(mess=="Lounge"){llRegionSay(giChan,"setmusic|http://scfire-ntc-aa04.stream.aol.com:80/stream/1009");llResetScript();}
if(mess=="Drum&Bass"){llRegionSay(giChan,"setmusic|http://207.200.96.229:8030");llResetScript();}
if(mess=="OldElectr"){llRegionSay(giChan,"setmusic|http://205.188.215.225:8004");llResetScript();}
if(mess=="Ambient"){llRegionSay(giChan,"setmusic|http://205.188.215.228:8006");llResetScript();}
if(mess=="Breaks"){llRegionSay(giChan,"setmusic|http://205.188.215.225:8002");llResetScript();}
if(mess=="FutureSyn"){llRegionSay(giChan,"setmusic|http://208.122.59.30:7234");llResetScript();}
if(mess=="Gabber"){llRegionSay(giChan,"setmusic|http://205.188.215.226:8006");llResetScript();}
}
}
state somafm{
state_entry(){
llListen(giDialog,"","","");
llDialog(gkDet,"Pick a station...",glS1,giDialog);
llSetTimerEvent(gfResetDelay);
}
timer(){llResetScript();}
on_rez(integer param){llResetScript();}
listen(integer chan,string name,key id,string mess){
if(mess=="2>"){llDialog(gkDet,"Pick a station...",glS2,giDialog);}
if(mess=="<1"){llDialog(gkDet,"Pick a station...",glS1,giDialog);}
if(mess=="-None-"){llRegionSay(giChan,"setmusic|");llResetScript();}
if(mess=="Lush"){llRegionSay(giChan,"setmusic|http://standby.somafm.com:8802");llResetScript();}
if(mess=="Digi"){llRegionSay(giChan,"setmusic|http://standby.somafm.com:8902");llResetScript();}
if(mess=="GrvSalad"){llRegionSay(giChan,"setmusic|http://207.200.96.226:8000");llResetScript();}
if(mess=="DrneZone"){llRegionSay(giChan,"setmusic|http://207.200.96.226:8002");llResetScript();}
if(mess=="SpaceSta"){llRegionSay(giChan,"setmusic|http://steady.somafm.com:8202");llResetScript();}
if(mess=="BeatBlnd"){llRegionSay(giChan,"setmusic|http://steady.somafm.com:8386");llResetScript();}
if(mess=="IndiePop"){llRegionSay(giChan,"setmusic|http://steady.somafm.com:8076");llResetScript();}
if(mess=="Cliqhop"){llRegionSay(giChan,"setmusic|http://steady.somafm.com:8080");llResetScript();}
if(mess=="SncVerse"){llRegionSay(giChan,"setmusic|http://standby.somafm.com:8602");llResetScript();}
if(mess=="ILstreet"){llRegionSay(giChan,"setmusic|http://steady.somafm.com:8502");llResetScript();}
if(mess=="BootLiqr"){llRegionSay(giChan,"setmusic|http://steady.somafm.com:7002");llResetScript();}
if(mess=="TagsTrip"){llRegionSay(giChan,"setmusic|http://205.188.234.9:8000");llResetScript();}
if(mess=="ScrtAgnt"){llRegionSay(giChan,"setmusic|http://207.200.96.228:8000");llResetScript();}
if(mess=="Doomed"){llRegionSay(giChan,"setmusic|http://steady.somafm.com:8302");llResetScript();}
}
}
Group relay
If the land you want to change the music url on is owned by a group, you need to use this relay script. Place it in a prim, and deed it to the group that owns the land. This script is also useful if you have more than one parcel of land in the same sim, and want to change the music in more than one place at the same time. Make sure the both the script and the prim have full permissions set before deeding so you can sell it back to yourself and make changes if needed.
integer giChan=8437; // replace this with something random, match with the tuner script
string gsOriginalMusic;
integer listen0;
default{
on_rez(integer param){llResetScript();}
state_entry(){llListen(giChan,"","","");}
listen(integer chan,string name,key id,string mess){
list lText=llParseString2List(mess,["|"],[]);
string s1=llList2String(lText,0);
string s2=llList2String(lText,1);
if(s1=="setmusic"){llSetParcelMusicURL(s2);}
}
}
fread.php
llHTTPRequest only supports the reading of certain filetypes, and *.pls is not one of them. This script will display any URL fed to it as text.
<?php
$file = $_GET['url'];
$handle = fopen($file, 'r');
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
print $contents;
?>