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 

dilemma with xsl and displaying now playing/listener stats

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



Joined: 06 Dec 2008
Posts: 2

PostPosted: Sat Dec 06, 2008 1:48 am    Post subject: dilemma with xsl and displaying now playing/listener stats Reply with quote

Hi everyone,

I am in the process of converting my old shoutcast station over to icecast and have run into a dilemma.

The setup I have is - a fallback "archive" mount and
a live dj mount

When no DJ is connected to the live mount, the archive is playing, and when the DJ connects the live mount becomes active and listeners on the fallback archive get moved over to the live stream.

What I need is to be able to display the now playing/listener stats on the front page of my website. This part is easy - however, the problem is that both archive and live mounts appear, but instead I want the live mount to be displayed if it is active, and the archive mount dispayed only when it is not.

The .xsl I am using is this:

Quote:
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
<xsl:output omit-xml-declaration="no" method="html" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" encoding="UTF-8" />
<xsl:template match = "/icestats" >
<html>
<body>
<div id='listener'>
<!--mount point stats-->
<xsl:for-each select="source">
<xsl:choose>
<xsl:when test="listeners">
<table border="0" cellpadding="4">
<tr><td><strong>Now Playing:</strong></td><td class="streamdata">
<xsl:if test="artist"><xsl:value-of select="artist" /> - </xsl:if><xsl:value-of select="title" /></td></tr>
<xsl:if test="bitrate">
<tr><td><strong>Bitrate:</strong></td><td class="streamdata"> <xsl:value-of select="bitrate" /></td></tr>
</xsl:if>
<xsl:if test="listeners">
<tr><td><strong>Current Listeners:</strong></td><td class="streamdata"> <xsl:value-of select="listeners" /></td></tr>
</xsl:if>
<xsl:if test="listener_peak">
<tr><td><strong>Peak Listeners:</strong></td><td class="streamdata"> <xsl:value-of select="listener_peak" /></td></tr>
</xsl:if>
</table>

</xsl:when>
<xsl:otherwise>
<h3><xsl:value-of select="@mount" /> - Not Connected</h3>
</xsl:otherwise>
</xsl:choose>

</xsl:for-each>
<xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


The output when JUST the archive mount is active is displayed as:

Quote:
Now Playing: MK ULTRA - Sell Your Soul To NRG (Hard House NRG Electronic Dance Music)
Bitrate: 8
Current Listeners: 0
Peak Listeners: 1


The output when both the archive mount and live mounts are active is displayed as:

Quote:
Now Playing: MK ULTRA - Sell Your Soul To NRG (Hard House NRG Electronic Dance Music)
Bitrate: 8
Current Listeners: 0
Peak Listeners: 1

Now Playing: LIVE DJ PLAYING
Bitrate: 24
Current Listeners: 0
Peak Listeners: 0


Can anyone help me with this please so that when the live mount is active, only it is displayed? Smile

Thanks!
Back to top
View user's profile Send private message
razametal



Joined: 03 Nov 2006
Posts: 24
Location: Manta - Ecuador

PostPosted: Sat Dec 06, 2008 5:06 am    Post subject: Reply with quote

Please, if you find the solution, share it Smile

Good luck.
_________________
Only The Good Die Young
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sat Dec 06, 2008 12:57 pm    Post subject: Reply with quote

There's 2 possible ways.

The most straight forward way is to introduce a local relay to bounce between the archive and live mountpoints, listener would stay on the relay mountpoint and the archive and live mountpoint would be marked hidden.

The second is to modify the xsl page to test for the live mountpoint name, if it exist display the information from that else display the information from archive.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
razametal



Joined: 03 Nov 2006
Posts: 24
Location: Manta - Ecuador

PostPosted: Sat Dec 06, 2008 3:48 pm    Post subject: Reply with quote

I'm done with the "Now Listening" issue.

On my icecast server I've created the file/usr/share/icecast/web/ listening.xsl :

Code:

<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1
.0" >
<xsl:output omit-xml-declaration="no" method="html" doctype-public="-//W3C//DTD
 XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-s
trict.dtd" indent="yes" encoding="UTF-8" />
<xsl:template match = "/icestats" >
<html>

<head>
<title>radiometal.mantavirtual.com</title>
<style type="text/css">
body, div {
   color: #7F8062;
   font-family:trebuchet ms, arial, sans-serif;
   font-size: 11px;
}
</style></head>


<body>
<div id='listener'>
<!--mount point stats-->
<xsl:for-each select="source">
<xsl:choose>

   <xsl:when test="listeners">
   <strong>Sonando : </strong><br />
   <xsl:if test="artist"><xsl:value-of select="artist" /> - </xsl:if><xsl:
value-of select="title" />
   <!-- <br />
   <xsl:if test="bitrate">
   <strong>Bitrate: </strong>
   <xsl:value-of select="bitrate" /></xsl:if> -->
   <br /><br />
   <xsl:if test="listeners">
   <strong>Usuarios conectados : </strong>
   <xsl:value-of select="listeners" /></xsl:if>
   <!-- <br />
   <xsl:if test="listener_peak">
   <strong>Peak Listeners: </strong>
   <xsl:value-of select="listener_peak" /></xsl:if> -->
</xsl:when>
<xsl:otherwise>
<h3><xsl:value-of select="@mount" /> - Not Connected</h3>
</xsl:otherwise>
</xsl:choose>

</xsl:for-each>
<xsl:text disable-output-escaping="yes">&amp;</xsl:text>nbsp;
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>



To display the title of the song I use the following iframe (I'm using wordpress) in a text widget:


Code:

<iframe src="http://my.icecastserver.com:8000/listening.xsl?mount=/razametal" style="width:170px; border-width:0px;" />\m/</iframe>


The widget is displaying the song current played.

I need to :
- find the way to auto-update the display of the track that is being played.
- make it display the track playing by the fallback-mount when the primary mount is not streaming.

Quote:
The output when both the archive mount and live mounts are active is displayed as:


To show only one mount you can use stats.xsl:

Code:
http://your.icecastserver.com:8000/stats.xsl?mount=/yourmountpoint

_________________
Only The Good Die Young
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
kranky



Joined: 06 Dec 2008
Posts: 2

PostPosted: Sun Dec 07, 2008 1:01 am    Post subject: Reply with quote

karlH wrote:
The second is to modify the xsl page to test for the live mountpoint name, if it exist display the information from that else display the information from archive.
karl.


How could this be done? I am a noob with xsl.
Back to top
View user's profile Send private message
wgato



Joined: 18 Aug 2008
Posts: 8
Location: 215

PostPosted: Sat Dec 20, 2008 7:35 pm    Post subject: Reply with quote

razametal

i am also trying to figure out how to auto update the track display.

please post if you figure it out!

i'm guessing add some kind of php script that checks to see if the xsl file has been updated, and if it has reload the page?

unfortunately i'm sure how to do that and dont know if that is the proper/best way.
Back to top
View user's profile Send private message
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