php icecast current song + artiest

Status
Niet open voor verdere reacties.

arjan445

Gebruiker
Lid geworden
8 okt 2010
Berichten
130
hoi,

ik draai nu sinds 1 dag of 2 mijn eigen icecast radio stream op 83.119.66.193:8000/play.m3u
maar ik wil op de site een script hebben staan liefst php waar de artiest en titel in wordt weergegeven,
bij vlc komt het al te staan dus die ontvangt de metadata van de stream.
maar heb al wat gegoogled en gevonden dat ik een php script moet maken wat een connectie maakt met 83.119.66.193:8000/status.xsl en daar de current song moet laten ophalen en die moet dan in het php script laden maar na een uurtje werken is er nog niks gelukt:( mijn server staat remote dus mijn website staat ergens anders.

alvast bedankt, arjan445
 
u werkt volgen volgende xml neem ik aan
Code:
<icecast>
    <limits>
        <clients>100</clients>
        <sources>2</sources>
        <threadpool>5</threadpool>
        <queue-size>524288</queue-size>
        <client-timeout>30</client-timeout>
        <header-timeout>15</header-timeout>
        <source-timeout>10</source-timeout>
        <burst-on-connect>1</burst-on-connect>
        <burst-size>65535</burst-size>
    </limits>
    <authentication>
        <source-password>****</source-password>
        <relay-password>****</relay-password>
        <admin-user>admin</admin-user>
        <admin-password>****</admin-password>
    </authentication>
 
    <hostname>localhost</hostname>
    <listen-socket>
        <port>8000</port>
    </listen-socket>
 
    <fileserve>1</fileserve>
 
    <paths>
        <basedir>./</basedir>
 
        <logdir>./logs</logdir>
        <webroot>./web</webroot>
        <adminroot>./admin</adminroot>
        <alias source=”/” dest=”/status.xsl”/>
    </paths>
 
    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
        <loglevel>4</loglevel> <!— 4 Debug, 3 Info, 2 Warn, 1 Error —>
        <logsize>10000</logsize> <!— Max size of a logfile —>
    </logging>
 
    <security>
        <chroot>0</chroot>
    </security>
</icecast>

en volgens volgend zoekresultaat(van:icecast radio streaming status.xsl) krijg je volgend

script ref:http://stackoverflow.com/questions/3489773/use-php-to-show-icecast2-statistics

PHP:
<?php

/*
 * SCRIPT CONFIGURATIONS
*/
$SERVER = 'http://myserver.com:8000'; //URL TO YOUR ICECAST SERVER
$STATS_FILE = '/status.xsl'; //PATH TO STATUS.XSL PAGE YOU CAN SEE IN YOUR BROWSER (LEAVE BLANK UNLESS DIFFERENT)

///////////////////// END OF CONFIGURATION --- DO NOT EDIT BELOW THIS LINE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

//create a new curl resource
$ch = curl_init();

//set url
curl_setopt($ch,CURLOPT_URL,$SERVER.$STATS_FILE);

//return as a string
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

//$output = our stauts.xsl file
$output = curl_exec($ch);

//close curl resource to free up system resources
curl_close($ch);

//build array to store our radio stats for later use
$radio_info = array();
$radio_info['server'] = $SERVER;
$radio_info['title'] = '';
$radio_info['description'] = '';
$radio_info['content_type'] = '';
$radio_info['mount_start'] = '';
$radio_info['bit_rate'] = '';
$radio_info['listeners'] = '';
$radio_info['most_listeners'] = '';
$radio_info['genre'] = '';
$radio_info['url'] = '';
$radio_info['now_playing'] = array();
   $radio_info['now_playing']['artist'] = '';
   $radio_info['now_playing']['track'] = '';

//loop through $ouput and sort into our different arrays
$temp_array = array();

$search_for = "<td\s[^>]*class=\"streamdata\">(.*)<\/td>";
$search_td = array('<td class="streamdata">','</td>');

if(preg_match_all("/$search_for/siU",$output,$matches)) {
   foreach($matches[0] as $match) {
      $to_push = str_replace($search_td,'',$match);
      $to_push = trim($to_push);
      array_push($temp_array,$to_push);
   }
}

//sort our temp array into our ral array
$radio_info['title'] = $temp_array[0];
$radio_info['description'] = $temp_array[1];
$radio_info['content_type'] = $temp_array[2];
$radio_info['mount_start'] = $temp_array[3];
$radio_info['bit_rate'] = $temp_array[4];
$radio_info['listeners'] = $temp_array[5];
$radio_info['most_listeners'] = $temp_array[6];
$radio_info['genre'] = $temp_array[7];
$radio_info['url'] = $temp_array[8];

$x = explode(" - ",$temp_array[9]);
$radio_info['now_playing']['artist'] = $x[0];
$radio_info['now_playing']['track'] = $x[1];

?>
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan