Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Currently Playing Song Title Data Question

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
Anonymous
Guest





PostPosted: Sun Jul 02, 2006 6:30 pm    Post subject: Currently Playing Song Title Data Question Reply with quote

Hi, is the admin/stats.xsl the only default way of getting the currently playing title track from IceCast? ShoutCast has the public /7.html page that returns data including the NOW PLAYING track name. Does IceCast have something similar that is publicly visible?

Yes figured it out - /status2.xsl has a now playing area


Last edited by Anonymous on Fri Jul 07, 2006 2:34 am; edited 1 time in total
Back to top
Anonymous
Guest





PostPosted: Fri Jul 07, 2006 1:46 am    Post subject: never mind... wrote it myself - here you go Reply with quote

Two useful php functions for icecast

- isIceCast($url) - will tell you if the url is an incecast server

- checkIceCastStatus($url) will tell you the NOW PLAYING track

Code:

/************************ isIceCast() *************************************/
//feed this function an m3u to determine if you have an icecast server
//it needs php > 4.3 for stream_get_meta_data() to work
function isIceCast($url)
{
//by streamfinder -at- gmail.com
//$url = 'http://stream.masterssystems.com:8000/rkr.ogg.m3u';
//$url = "http://201.6.214.205:8000/stream.mp3.m3u";
//dont work $url = "http://s1.pop-stream.de:8034/listen.pls";
$stream = rtrim(file_get_contents($url));
$fp = fopen($stream,'r');
$data = stream_get_meta_data($fp);
//print_r($data);
$result = false;
foreach($data[wrapper_data] as $line)
{ echo $line.'<br>';
if(substr($line,0,15)=='Server: Icecast'){ $result = true;}      
}
return $result;
}

/*********************** checkIceCastStatus() *****************************/
//feed this function a icecast server url to status2.xsl
function checkIceCastStatus($url)
{
// by streamfinder -at- gmail.com   

//sample xsl needed
//$url = 'http://vapid.reprehensible.net:6500/status2.xsl';

$lines = file($url); //read status2.xsl into an array

if($lines == false) { $text = false; }
else
{

//find the line with the header columns
$key = array_search("MountPoint,Connections,Stream Name,Current Listeners,Description,Currently Playing,Stream URL \n",$lines);
//mount points and now playing occur two lines later
$mntkey = ($key + 2);
//echo 'Mountkey = '.$mntkey;
$mntpnt = explode(',',$lines[$mntkey]);
$i = 0; //initialize counter
$song = ''; //initialize song name
while($song == '' && $i < 100) //try to find a song title it is 5 keys away from the mountpoint beginning with a slash / - 100 is our timeout
{
//check if first character is a slash /
if($mntpnt[$i]{0} == '/')
   //we have a mountpoint
   {
      if($mntpnt[$i+5] != '' && $mntpnt[$i+5] != " - ")
      //we have a song title
      { $song = $mntpnt[$i+5]; }
   } //no song title, check next line
$i++;   

}

if($song != '') {
$text = 'Now Playing(icecast): '.$song;
} else { $text = 'Now Playing(icecast): unknown'; }

}
return $text;
}


Hope you find these useful - I am open to suggestions and improvements
Back to top
Anonymous
Guest





PostPosted: Mon Jul 10, 2006 5:28 pm    Post subject: solution for ICES Reply with quote

Here is what I did using the ICES que file. Only for ICES sources though, not a general ICECAST solution:

Have a php file called current_tune.php:

<?php

$filename = "/tmp/ices.cue";
$handle = fopen($filename, "r");

$contents = fread($handle, filesize($filename));

list($fname,$size,$bitrate,$length,$pct,$idx,$artist,$title) = split("\n",$contents);

fclose(handle);

echo "Now playing:".$artist."<BR>";
echo $title;

?>

Then, whenever I want to display the current track, I just include:

<?php @include_once('current_tune.php'); ?>

cheers! Smile
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber