| View previous topic :: View next topic |
| Author |
Message |
kranky
Joined: 06 Dec 2008 Posts: 2
|
Posted: Sat Dec 06, 2008 1:48 am Post subject: dilemma with xsl and displaying now playing/listener stats |
|
|
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">&</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?
Thanks! |
|
| Back to top |
|
 |
razametal

Joined: 03 Nov 2006 Posts: 24 Location: Manta - Ecuador
|
Posted: Sat Dec 06, 2008 5:06 am Post subject: |
|
|
Please, if you find the solution, share it
Good luck. _________________ Only The Good Die Young |
|
| Back to top |
|
 |
karlH Code Warrior

Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Sat Dec 06, 2008 12:57 pm Post subject: |
|
|
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 |
|
 |
razametal

Joined: 03 Nov 2006 Posts: 24 Location: Manta - Ecuador
|
Posted: Sat Dec 06, 2008 3:48 pm Post subject: |
|
|
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">&</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 |
|
 |
kranky
Joined: 06 Dec 2008 Posts: 2
|
Posted: Sun Dec 07, 2008 1:01 am Post subject: |
|
|
| 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 |
|
 |
wgato
Joined: 18 Aug 2008 Posts: 8 Location: 215
|
Posted: Sat Dec 20, 2008 7:35 pm Post subject: |
|
|
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 |
|
 |
|