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 

Now playing in web page
Goto page 1, 2, 3  Next
 
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: Thu Jan 18, 2007 12:23 am    Post subject: Now playing in web page Reply with quote

How would I go about including the "Song" information from the icecast page into a webpage with my design? As I plan to link people to the stream files from my webpage, and not from the actual icecast page on port 8000.

My server supports ASP PHP Perl and CGI if it matters
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Thu Jan 18, 2007 2:45 am    Post subject: Reply with quote

You could write your own xsl page that will present that page or be included into your own web page, or you could parse the xml stats yourself and present the information in your script.

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





PostPosted: Fri Jan 19, 2007 1:28 am    Post subject: Reply with quote

how would i make this xsl code? I'm not fluent with xml.
Back to top
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Fri Jan 19, 2007 1:35 am    Post subject: Reply with quote

You have to pick which way is best for you. You can look at what the shipped xsl pages do.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jcr
Modérateur français
Modérateur français


Joined: 14 Apr 2006
Posts: 544
Location: France, Auvergne

PostPosted: Fri Jan 19, 2007 8:41 am    Post subject: Reply with quote

Here is a sample getradiostatus.xsl page we use for FlyDance Radio:
Code:
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
<xsl:output omit-xml-declaration="no" method="xml" 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" >
<pre>
MountPoint,Server Name,Description,Data Type,Bitrate,Quality,Video Quality,Frame Size,Frame Rate,Listeners,Peak Listeners,Genre,Server URL,Artist,Title
<xsl:for-each select="source">
<xsl:value-of select="@mount" />|<xsl:value-of select="server_name" />|<xsl:value-of select="server_description" />|<xsl:value-of select="server_type" />|<xsl:value-of select="bitrate" />|<xsl:value-of select="quality" />|<xsl:value-of select="video_quality" />|<xsl:value-of select="frame_size" />|<xsl:value-of select="frame_rate" />|<xsl:value-of select="listeners" />|<xsl:value-of select="listener_peak" />|<xsl:value-of select="genre" />|<xsl:value-of select="server_url" />|<xsl:value-of select="artist" />|<xsl:value-of select="title" />
_END_
</xsl:for-each>
</pre>
</xsl:template>
</xsl:stylesheet>

This builds a very simple response page we then parse with some php and display in a module on site. Here is a sample PHP 5 script wich has the job done.
As we use a fallback stream to an internally managed ices playlist, ironically named DJ Robot, we have some chak code included. You might have to adjust the script if you're not running it as a Joomla module
Code:
<?php
# Don't allow direct acces to the file
# mamboserver/Joomla specific
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
 
$radioname = 'FlyDance' ;  // Your radio name here
$host = 'www.flydance.eu' ; // Icecast host to connect to
$port = '8020' ;  // Icecast port
$pic = '<img src="/images/stories/djmix.png" align="center" border=0 width="64" height="64" alt="Ecoutez Flydance" title="Cliquez pour écoutez FlyDance" />';  // This sis the Listen to the radio icon
$djrobot = '/jrplay'; // Our playlist fallback mount..
$realdj = '/jrlive' ; // On air DJ stream

$listen = '<a href="http://www.flydance.eu:8020/jrlive.m3u">' . $pic . '</a><br />'; // Direct listen to us link

/**
 * Lab Radio
*/
// Get server stream status...
$msg = http_get( "http://$host:$port/getradiostatus.xsl" ) ;
// Clean up response and fill an array with active streams.
$spl = explode( '<pre>', $msg ) ;
$spl = str_replace( '</pre>', '', $spl[1] ) ;
$spl = explode( "<br/>", $spl ) ;
$flds = $spl[0] ;
$spl = explode( "\n", $flds ) ;
array_shift( $spl ) ;
// Build stations information.
$stations = array() ;
foreach ( $spl as $e ) {
   if ( ( $e !== '_END_' ) && !empty( $e ) ) {
               // Only for valid stations, reject empty and marker tags
      $p = explode( '|', $e ) ;
      $stations[$p[0]]['Name'] = $p[1] ;
      $stations[$p[0]]['Description'] = $p[2] ;
      $stations[$p[0]]['Listeners'] = $p[9] ;
      $stations[$p[0]]['Peak'] = $p[10] ;
      $stations[$p[0]]['Artist'] = $p[14] ;
      $stations[$p[0]]['Title'] = $p[13] ;
   }
}
// Get Fallback playlist information first...
$curtitle = $stations[$djrobot]['Title'] ;
$curartist = $stations[$djrobot]['Artist'] ;
$listeners = $stations[jrobot]['Listeners'] ;
$peak = $stations[$djrobot]['Peak'] ;
$stream = $stations[$djrobot]['Name'] ;
echo $listen . "\n" ;
if ( !empty( $stations[$realdj]['Name'] ) ) {
   $curtitle = $stations[$realdj]['Title'] ;
   $curartist = $stations[$realdj]['Artist'] ;
   $listeners = $stations[$realdj]['Listeners'] ;
   $peak = $stations[$realdj]['Peak'] ;
   $stream = str_replace( 'on FlyDance', '', $stations[$realdj]['Name'] ) ;
}
// Sanitize information, just for being sure it looks nice
$curtitle = str_replace( '_', '', $curtitle ) ;
$curartist = str_replace( '_', '', $curartist ) ;
echo '<font size="+1"><strong>' . $listeners .'</strong></font> (' . $peak . ') auditeurs écoutent<br />' ;
echo "DJ: <strong>$stream</strong><br />" ;
echo "$curartist<br />" ;
?>
  </center> <br/>
</div>

Result can be seen on Radio home page
_________________
Epsilon Friends Radio Icecast Radio on CentovaCast admin panel. Icecast hosting
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Anonymous
Guest





PostPosted: Fri Jan 19, 2007 10:01 pm    Post subject: Reply with quote

Hello, I am desigining my own pages in PHP. But I can also make ASP or HTML or XML pages. I am not using Joomla or Mambo OS. I just need the simple code for song and listener data that can be included in a php page.

Would I save that particular xsl page as a ".xml" or ".xsl"? And then just PHP INCLUDE it?
Back to top
Anonymous
Guest





PostPosted: Fri Jan 19, 2007 10:44 pm    Post subject: Reply with quote

Also, when using the code above, I get the following error:
(sorry for double posting)


"Fatal Error: Call to undefined function: http_get() in -------- on line 39"
(-------- is my server roots etc, hiding for security)

And then when changing http_get ( "xsl file url" ) to include then i just get a page that is nothing but some courier text that says

|||||||||||||||||||||| _END
or something like that.

After this, i see the listen button and:
() auditers ecountent
DJ:

And nothing after "DJ:"

What perhaps am i doing wrong??
Back to top
jcr
Modérateur français
Modérateur français


Joined: 14 Apr 2006
Posts: 544
Location: France, Auvergne

PostPosted: Sat Jan 20, 2007 10:50 am    Post subject: Reply with quote

Quote:
"Fatal Error: Call to undefined function: http_get() in -------- on line 39"

I see. http_get() call is part of HTTP pecl extension, not part of stock PHP. This extension allows browser like operations. http://pecl.php.net/package/pecl_http

Without it you have to query icecast by other scripts and get te result page.

Quote:
And then when changing http_get ( "xsl file url" ) to include then i just get a page that is nothing but some courier text that says

xsl file has to be in your icecast installation, typically for Fedora Linux, in /usr/share/icecast/web directory (adjust for your installation). After installing xsl, check with your broser. You should have one or more lines like :
Quote:

MountPoint,Server Name,Description,Data Type,Bitrate,Quality,Video Quality,Frame Size,Frame Rate,Listeners,Peak Listeners,Genre,Server URL,Artist,Title
/jrlive|Hermites On Flydance|house|audio/mpeg|128|||||1|1|Various|http://www.flydance.eu||Kash Vs INXS - Dream On Black Girl
_END_
/jrplay|DJ Robot on FlyDance|Automatic Robot Music Player|audio/mpeg||||||0|19|Electro|http://www.flydance.eu/||Metallica - Wherever I May Roam
_END_

When this works in your brower, PHP scrip works the same. http_get() function connects to icecast in the same way your browser does.
All other processing in php code is only parsing the result to have arrays of information about the streams.
_________________
Epsilon Friends Radio Icecast Radio on CentovaCast admin panel. Icecast hosting
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Anonymous
Guest





PostPosted: Sat Jan 20, 2007 2:55 pm    Post subject: Reply with quote

I'm really a PHP noob and a server one at that, i dont even own the server. I am running Windows Server 2003. I understand that PHP is just making some sense out of the several lines of crap that XSL is feeding. And, I do not have this "DJ robot". We are just having scheduled DJs sign on using Oddcast Winamp Plugin and playing music/doing talk shows.

On Windows Server 2003, how would i install this PECL extension? Is this server-side only, or would the page viewers need it installed too?

I don't know where the XSL file is in my icecast installation. Perhaps the reason I just got empty information ||||||||||||||||| _END_ from my file is because I just copy-pasted the .xsl sample file that you (jcr) gave me earlier, and saved it in the same directory as my PHP page.

The server that is hosting the site for the radio station, and the server running icecast, are two completely different boxes.

Is "getradiostatus.xsl" default in my installation of Icecast 2? Can I install it somewhere on Icecast? And what directory to put it in Windows 2k3?

I really appreciate all your help, and I'm sorry for being such a noob at this. That's kinda why i'm asking for help, lol.

EDIT!!!!!! I just realized, the site is being hosted on Linux. What type of Linux, I don't know, but i'm sure they're mostly the same. The server hosting Icecast however still runs Win2k3.
Back to top
jcr
Modérateur français
Modérateur français


Joined: 14 Apr 2006
Posts: 544
Location: France, Auvergne

PostPosted: Sat Jan 20, 2007 9:31 pm    Post subject: Reply with quote

PHP PECL extensions should compile on Windows too Wink
They are only on server, as it is real PHP code, extending the base language.

Most Linux installs can have extensions easily built using the phpize, make and make install magic commandes Wink

I don't ghave a windows box, but I guess icecast windows installs in a diectory of his own. There you'll find a web directory, where you can drop xsl file.
_________________
Epsilon Friends Radio Icecast Radio on CentovaCast admin panel. Icecast hosting
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Anonymous
Guest





PostPosted: Sun Jan 21, 2007 12:52 pm    Post subject: Reply with quote

Greetings, I have successfully put the XSL in \Program Files\Icecast2 Win32\web and now instead of "Cant parse XSL file" I get a readout of what is currently playing, divided by a bunch of | symbols and crap.

However, apparently PECL is not working. We are trying to install it on Linux--(Icecast machine still working on Windows)--and according to my server's root administrator, it's very very hard to install. Is there something we're doing wrong?? LX commands are hard apparently, I guess.... Any suggestions? I dont know any LX commands, so maybe I can get my server admin join here and post about the errors.
Back to top
Anonymous
Guest





PostPosted: Sun Jan 21, 2007 4:31 pm    Post subject: Reply with quote

We are now trying install on Windows, and still having trouble, though I'm not exactly sure what the trouble is. This is the page...so far...at least. It says Fatal Error still for me. http://www.cyber-fm.com/now_playing.php
Back to top
jcr
Modérateur français
Modérateur français


Joined: 14 Apr 2006
Posts: 544
Location: France, Auvergne

PostPosted: Sun Jan 21, 2007 9:38 pm    Post subject: Reply with quote

spinbga wrote:
However, apparently PECL is not working. We are trying to install it on Linux--(Icecast machine still working on Windows)--and according to my server's root administrator, it's very very hard to install. Is there something we're doing wrong?? LX commands are hard apparently, I guess.... Any suggestions? I dont know any LX commands, so maybe I can get my server admin join here and post about the errors.


To compile PECL extensions for Linux, the easy way is installing distribution standard php-devel package. This includes a very handy script: phpize

When you download a PECL extension, installing it in PHP is as easy as:
Code:

# unpacking the package
tar xzvf php_pecl-x.x.tgz
cd php_pecl
phpize
make
su -c make install

Then, in your php.ini (or maily in a php.d subdirectory) add the following to configure default behaviour of the extension:
Code:

; Enable the http extension module
extension=http.so

; the hashing algorithm with wich ETags are generated (MD5, SHA1, CRC32B)
; if ext/hash is available, this can be set to any hash algorithm ext/hash supports
; MD5 is the default and fallback algorithm
http.etag.mode = "MD5"

; allowed request methods
; by default PHP ignores unkown request methods
; PHP will exit with a response status of 405 and an Allow header
; if it encounters a request method not contained in the specified list
http.request.methods.allowed = "HEAD, GET, POST"

; custom request methods
http.request.methods.custom = "KICK, BANN"

; log file for positive cache hits
;http.log.cache =

; log file for redirects
;http.log.redirect =

; log file for responses with http_send_file() etc. where the file's not been found
;http.log.not_found =

; log file for requests with an unallowed request method
;http.log.allowed_methods =

; composite log file (i.e. log all messages to this file)
;http.log.composite =

; automatically deflate content if requested/supported by client
http.send.deflate.start_auto = 1
http.send.deflate.start_flags = HTTP_DEFLATE_LEVEL_DEF

; automatically inflate sent content
;http.send.inflate.start_auto = 0
;http.send.inflate.start_flags =

; global HttpRequestDataShare settings
;http.request.datashare.cookie = 0
;http.request.datashare.dns = 1


On windows, if you have full PHP install, i Guess you can use the same procedure to install PECL extensions.

A working module can be seen at http://www.flydance.eu/
_________________
Epsilon Friends Radio Icecast Radio on CentovaCast admin panel. Icecast hosting
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Anonymous
Guest





PostPosted: Mon Jan 22, 2007 1:53 am    Post subject: Reply with quote

Hello, jcr, as you can see, i think we must've gotten installed correctly, because now we get a Parse error: T_STRING unexpected - but that's coming from YOUR xsl file as i have not yet changed the settings of the PHP code you provided me. but now it's obviously fetching something, which is good right? But why do we have the T_STRING error?

P.S. still on linux right now

Thanks,
spin
Back to top
jcr
Modérateur français
Modérateur français


Joined: 14 Apr 2006
Posts: 544
Location: France, Auvergne

PostPosted: Mon Jan 22, 2007 11:17 am    Post subject: Reply with quote

Checking your link http://www.cyber-fm.com/now_playing.php results in this error result:
Quote:
Parse error: syntax error, unexpected T_STRING in http://www.flydance.eu:8020/getradiostatus.xsl on line 1

which sounds weird, as xsl response for getradiostatus.xsl is a simple text file, so it is a string.

So, now, your settings obviously try checking something, but mightbe not what is expected. I tried to figure out what could happen, and finally got the same result when removing the ini for http extension, just loading the extension.
Check ini portion, could be a commented out line in it.

On all our servers here, PHP configuration is this one : http://www.lab-project.net/cx/cx.php

I didn't check everything on other setups however.
_________________
Epsilon Friends Radio Icecast Radio on CentovaCast admin panel. Icecast hosting
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
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