Old 18th March 2006, 21:51   #1
theattitude
Junior Member
 
Join Date: Oct 2004
Location: Fort Wayne, IN
Posts: 48
Send a message via AIM to theattitude Send a message via Yahoo to theattitude
PHP variables into Flash

How can I load in the following PHP variables into Flash?


This is the output for my PHP Code
The PHP filename is "radio_stats.php"
PHP Code:
if($streamstatus == "1"){
echo
'
&air=<B>ON THE AIR: 24/7/365</B>
&listen=<B>Listeners:  '
.$currentlisteners.' / '.$maxlisteners.'</B>
&cs=<B>'
.$song[0].'</B>
'
;
}
if(
$streamstatus == "0")
{
echo
'
&air=<B>TEMPORALLY OFF THE AIR</B>
&listen=<B>UNAVAILABLE</B>
&cs=<B>UNAVAILABLE</B>
'

this gives an output like this:

&air=ON THE AIR: 24/7/365 &listen=Listeners: 4 / 60 &cs=Linkin Park - Somewhere I Belong
theattitude is offline   Reply With Quote
Old 19th March 2006, 06:01   #2
networknova
Senior Member
 
Join Date: Mar 2005
Location: ontario
Posts: 402
Send a message via Yahoo to networknova
look into "echo" and "rawurlencode"
networknova is offline   Reply With Quote
Old 19th March 2006, 18:39   #3
theattitude
Junior Member
 
Join Date: Oct 2004
Location: Fort Wayne, IN
Posts: 48
Send a message via AIM to theattitude Send a message via Yahoo to theattitude
I do not think the PHP is the problem. I think it is the Action script. I can not figure out how to Load the Variables into Flash. I have tried a lot of ways, but ever time I run the flash it tells me they are undefined. Doese anyone know how to load the variables into Flash from a PHP file?
theattitude is offline   Reply With Quote
Old 20th March 2006, 23:08   #4
theattitude
Junior Member
 
Join Date: Oct 2004
Location: Fort Wayne, IN
Posts: 48
Send a message via AIM to theattitude Send a message via Yahoo to theattitude
I got it all figured out except for one thing. Flash stops reading in the variables at the ' sign. but here is the code incase you are wondering how to do this for your site.

PHP Code save as "config_radio.php"
PHP Code:
<?php
$scdef 
"";//Keep as is it was for a message             
$scip "IP";//IP adress
$scport "port";//port #
$scpass "changeme";//stream admin Password if you dident change it it is changeme
?>
PHP Code save as "radio_stats.php"
PHP Code:
<?php
// Shoutcast Server Stats
// Parses shoutcasts xml to make an effective stats thing for any website
// ©2004-2005 Daniel Brown [url]http://www.gmtt.co.uk[/url]
// Please refer to the readme file for use.


// Add-On MAXLISTNERS insead of the / 10 MAXLISTENERS which was set, and the BITRATE add-on.
// Online and Offline graphics, and add-on code.
// Better HTML Script.

// Do Not Try To Edit This Only Unless You Know What You're Doing!!!!!!!
include('config_radio.php');

$scfp fsockopen("$scip"$scport, &$errno, &$errstr30);
 if(!
$scfp) {
  
$scsuccs=1;
echo
''.$scdef.' is Offline'
 }
if(
$scsuccs!=1){
 
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
 while(!
feof($scfp)) {
  
$page .= fgets($scfp1000);
 }
######################################################################################################################
/////////////////////////part 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//define  xml elements
 
$loop = array("STREAMSTATUS""BITRATE""SERVERTITLE""CURRENTLISTENERS""MAXLISTENERS""BITRATE");
 
$y=0;
 while(
$loop[$y]!=''){
  
$pageed ereg_replace(".*<$loop[$y]>"""$page);
  
$scphp strtolower($loop[$y]);
  $
$scphp ereg_replace("</$loop[$y]>.*"""$pageed);
  if(
$loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
   $
$scphp urldecode($$scphp);

// uncomment the next line to see all variables
//echo'$'.$scphp.' = '.$$scphp.'<br>';
  
$y++;
 }
//end intro xml elements
######################################################################################################################
######################################################################################################################
/////////////////////////part 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//get song info and history
 
$pageed ereg_replace(".*<SONGHISTORY>"""$page);
 
$pageed ereg_replace("<SONGHISTORY>.*"""$pageed);
 
$songatime explode("<SONG>"$pageed);
 
$r=1;
 while(
$songatime[$r]!=""){
  
$t=$r-1;
  
$playedat[$t] = ereg_replace(".*<PLAYEDAT>"""$songatime[$r]);
  
$playedat[$t] = ereg_replace("</PLAYEDAT>.*"""$playedat[$t]);
  
$song[$t] = ereg_replace(".*<TITLE>"""$songatime[$r]);
  
$song[$t] = ereg_replace("</TITLE>.*"""$song[$t]);
  
$song[$t] = urldecode($song[$t]);
  
$dj[$t] = ereg_replace(".*<SERVERTITLE>"""$page);
  
$dj[$t] = ereg_replace("</SERVERTITLE>.*"""$pageed);
$r++;
 }
//end song info
fclose($scfp);
}
//display stats
/*-------------
On Air  status
-------------*/
if($streamstatus == "1"){
echo 
'&air= 1';//this is what i used as a variable to determine that the station was on
echo '&clisten= '.$currentlisteners.'';//current listeners
echo '&mlisten= '.$maxlisteners.'';//Maximum listeners
echo "&cs= $song[0]";//current song
}
/*-------------
Off Air  status
-------------*/
if($streamstatus == "0")
{
echo 
'&air= 0';//this is what i used as a variable to determine that the station was off
echo '&clisten= '.$currentlisteners.'';//current listeners should be 0 since it is off
echo '&mlisten= '.$maxlisteners.'';//Maximum listeners should be 0 since it is off
echo "&cs= $song[0]";//current song should be 0 since it is off
/*--------------------------------------------------------------------------------
Current song for more just add another echo like echo="&s1= $song[1]"; just 
keep adding one to them your input variable in flash will be myLoadVars_lv.s1
and so on incrementing by one. 
--------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------
As for the time played you will also have to input then using another echo command
this would be echo="t0= $playedat[0]"; for current song and just add one to those
for previous songs. Reminder your input variable in flash will be myLoadVars_lv.t0
for the first one and so on incrementing by one.
--------------------------------------------------------------------------------*/
}
?>
And for the flash I also have 2 codes one for frame 1 and the other for frame 360 which is 30 seconds into it. You can adjust that to whatever you want for the refresh. Your FPS times seconds. This refresh dose not work in IE but it dose in FireFox.

Frame 1 code
code:

/*--------------------------------
creates a variable to load in the
PHP variables
---------------------------------*/
var myLoadVars_lv = new LoadVars();
/*--------------------------------
What happens if it loads the
variables in successfully
---------------------------------*/
myLoadVars_lv.onLoad = function( success )
{
/*--------------------------------
One last chance to load the variables
---------------------------------*/
if (myLoadVars_lv.air==0){
myLoadVars_lv.load("radio_stats.php");
}
/*--------------------------------
Display message if on air the <B> and
</B> makes the text bold if they are
read in as HTML
---------------------------------*/
if (myLoadVars_lv.air==1){
air = "<B>ONLINE 24/7/365</B>";
/*--------------------------------
Display listeners message if on air the
Listeners: current / max
---------------------------------*/
listen= "<B>Listeners: " + myLoadVars_lv.clisten +" / "+ myLoadVars_lv.mlisten + "</B>";
/*--------------------------------
Display Current song if on air the
Currrent Song: current song
---------------------------------*/
cs="<B>Currrent Song: " + myLoadVars_lv.cs + "</B>";

/*--------------------------------
Display Current song if off air the
you get the picture
---------------------------------*/
} else{
air = "<B>Temporarily Offline</B>";
listen= " ";
cs=" ";
}


}
/*--------------------------------
Loads in the variables
---------------------------------*/
myLoadVars_lv.load("radio_stats.php");



Frame 360 Code
code:

/*----------------------------------------
This code is just to make the status blank
before it reloads variables on frame one
----------------------------------------*/
air = "";
listen= " ";
cs=" ";
gotoAndPlay(1);


Oh ya a working version of this will be at http://www.theattitude.org/
theattitude is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Shoutcast > Shoutcast Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump