<?php $fl = file_get_contents('http://ra-light.ru:8000/status.xsl?mount=/light_pop'); function antara($string, $start, $end){ $string = " ".$string; $ini = strpos($string,$start); if ($ini == 0) return ""; $ini += strlen($start); $len = strpos($string,$end,$ini) - $ini; return substr($string,$ini,$len); } $song = antara($fl, "<td>Current Song:</td>\n<td class=\"streamdata\">", "</td>"); echo '<span class="track">'.$song.'</span>'; ?>
<script type="text/javascript"> $.ajax({ url: 'прямой адрес к PHP файлу', success: function(data) { $('#trackholder').html(data); }}); function refresh() { $.ajax({ url: 'прямой адрес к PHP файлу', success: function(data) { $('#trackholder').html(data); }}); }; setInterval(refresh, 5000); </script>
<!-- WARNING: DO NOT ATTEMPT TO PARSE ICECAST HTML OUTPUT! The web interface may change completely between releases. If you have a need for automatic processing of server data, please read the appropriate documentation. Latest docs: ********** -->
<script> function show_station_title() { $.getJSON('http://ra-light.ru:8000/status-json.xsl?mount=/nonstop', function(data) { $('.track_title').html(data.icestats.source.title); }) } $(document).ready(function() { show_station_title(); setInterval('show_station_title()', 3000) }); </script>
<script> function show_station_server_description() { $.getJSON('мой сайт/status-json.xsl?mount=/nonstop', function(data) { $('.track').html(data.icestats.source.server_description); }) } $(document).ready(function() { show_station_server_description(); setInterval('show_station_server_description()', 3000) }); </script>
{"icestats":{"admin":"icemaster@localhost","host":"localhost","location":"Earth","server_id":"Icecast 2.4.99.1","server_start":"Mon, 10 Aug 2015 09:10:35 -0700","server_start_iso8601":"2015-08-10T09:10:35-0700","authentication":[null,null,null]}}
// Парсим лайв if( !data.icestats.source || !data.icestats.source.server_description ) { // Парсим nonstop }
<script> function show_station_server_description() { $.getJSON('адрес/status-json.xsl?mount=/live', function(data) { if( !data.icestats || !data.icestats.source || !data.icestats.source.server_description ) { $.getJSON('адрес/status-json.xsl?mount=/nonstop', function(data) { if( !data.icestats || !data.icestats.source || !data.icestats.source.server_description ) $('.track').html( 'Поток выключен' ); else $('.track').html(data.icestats.source.server_description); }); } else $('.track').html(data.icestats.source.server_description); }); } $(document).ready(function() { show_station_server_description(); setInterval('show_station_server_description()', 3000) }); </script>