|
Bloo
|
 |
Join Date: Sep 2006
Location: San Antonio, Texas
Posts: 185
|
|
Radio + Shoutcast
OK, I tinkered with Rapidwolve's Radio script (see Code Gallery), and tried to add Shoutcast (*.pls) stream support, but it's not working 
Everything works EXCEPT the actual music.
Can anyone find the thing I must have overlooked?
PHP Code:
function onActionServerside(action)
{
switch (action)
{
case "updateChannel":
findNPC("RadioServer").refresh(params[1]);
break;
}
}
public function updateChannelVars(dj, text, song, djhead){
player.triggerClient("gui", name, "recRadioParams", dj, text, song, djhead);
}
//#CLIENTSIDE
function onCreated()
setVars();
function onActionClientside(action){
switch (action)
{
case "recRadioParams":
updateChannelVars(params[1], params[2], params[3], params[4]);
break;
}
}
function onKeyPressed(code, key)
{
if (client.radio = true)
if (key in serverr.radio.validstations)
doChangeStation(key);
}
function onWeaponFired()
toggleRadio();
function setVars(){
if (client.radiochannel == null)
client.radiochannel = 1;
updateChannel(client.radiochannel);
client.radio = false;
this.sx = screenwidth - (32 * 9.5);
this.sy = 35;
this.font = "Arial";
this.fontsize = 0.65;
this.textstyle = "b";
stopmidi();
}
public function updateChannelVars(dj, rtext, song, djhead){
if (temp.song.pos(".pls") > -1)
{
this.req = requestURL(temp.song);
catchevent(this.req, "onReceiveData", "onData1");
this.rtype = 2;
}
else
{
this.song = temp.song;
this.rtype = 1;
}
this.djhead = temp.djhead;
this.rtext = temp.rtext;
this.dj = temp.dj;
}
function onData1(obj)
{
for (line: obj.data)
{
if (line.starts("File1="))
{
this.song = line.substring(6);
break;
}
}
this.req = NULL;
}
function onMusicDataReceived(dataname, datavalue) {
if (dataname == "ATRIST")
this.artist = datavalue;
else if (dataname == "TITLE")
this.songname = datavalue;
echo("music status: " @ getMusicStatus());
echo("music info: " @ getMusicTags());
}
public function updateChannel(channel)
{
triggerServer("gui", name, "updateChannel", channel);
}
public function doChangeStation(channel){
updateChannel(channel);
client.radiochannel = channel;
}
public function toggleRadio(){
if (client.radio == false)
{
client.radio = true;
drawRadio();
setTimer(.05);
}
else
{
destroyRadio();
setTimer(0);
}
}
function drawRadio(){
updateChannel(client.radiochannel);
client.radio = true;
player.addMessage("You turned your radio on.");
onTimeout();
}
function destroyRadio(){
client.radio = false;
player.addMessage("You turned your radio off.");
stopmidi();
hideimgs( -1, 1000);
}
function onTimeout(){
showimg(202, this.djhead, this.sx, this.sy - 25);
changeimgvis(202, 4);
changeimgpart(202, 3, 69, 26, 23);
showText(200, this.sx + 140, this.sy - 25, this.font, "ic", serverr.("radio" @ client.radiochannel @ "name") SPC "via" SPC (this.rtype == 1 ? "MP3" : "Shoutcast"));
changeimgvis(200, 7);
changeimgzoom(200, this.fontsize - 0.1);
showText(201, this.sx + 140, this.sy - 10, this.font, "ic", this.dj);
changeimgvis(201, 7);
changeimgzoom(201, this.fontsize - 0.1);
if (this.rtype == 2)
{
showText(211, this.sx + 70, this.sy + 25, this.font, "c", "\"" @ this.songname @ "\"");
changeimgvis(211, 7);
changeimgzoom(211, this.fontsize - 0.15);
showText(210, this.sx + 70, this.sy + 35, this.font, "c", "by" SPC this.artist);
changeimgvis(210, 7);
changeimgzoom(210, this.fontsize - 0.15);
}
else
{
hideimg(210);
hideimg(211);
}
tokens = wraptext2(255, this.fontsize, " ", this.font @ "@" @ this.fontstyle @ "@" @ this.rtext);
hideimgs(250, 300);
for (this.i = 0; this.i < tokens.size(); this.i++)
{
showText(250 + this.i, this.sx, this.sy + (this.i * 15), this.font, this.textstyle, tokens[this.i]);
changeimgvis(250 + this.i, 7);
changeimgzoom(250 + this.i, this.fontsize);
}
if (this.song != NULL)
{
if (this.rtype == 1)
playlooped(this.song);
else if (this.rtype == 2)
play(this.song);
}
else
stopmidi();
setTimer(0.05);
}
|
__________________
Trying to be nice now...
|
|