thyagoluciano / flutter_radio

Radio station streaming example with ExoPlayer and Flutter.
GNU General Public License v3.0
86 stars 41 forks source link

get stream info #48

Closed alainseys closed 3 years ago

alainseys commented 4 years ago

Hello can i get radio stream information from to the flutter application using this ?

if so can you tell me what do i need to implement to perform this (the radio stream haves the information in the xml metadata)

thanks

sarbazx commented 4 years ago

@thyagoluciano is it possible?

alainseys commented 4 years ago

@sarbazx i have done this by calling a php api where i get the stream information. the server is using a icecast2 server

alainseys commented 4 years ago

this is de code of php api

function CallIcecastXSPF($XSPFurl){ //$XSPFurl = 'http://127.0.0.18000/stream_192.xspf'; $xml = simplexml_load_file($XSPFurl); $stream['info']['title'] = (string) $xml->trackList->track->title; $stream['info']['location'] = (string) $xml->trackList->track->location; $stream['info']['server_description'] = (string) $xml->trackList->track->annotation;

 `preg_match_all('/^(.*):(.*)/m',` (string) $xml->trackList->track->annotation,$matches);
 if(isset($matches[1]) && isset($matches[2]) && isset($matches[3])){
     $t = array_combine($matches[1], $matches[2], $matches[3]);
     foreach($t as $key => $val){
         $fkey = str_replace(" ", "_",$key);
         $stream['info'][strtolower($fkey)] = trim($val);
     }
 }
 return $stream;

} `