0

I post here, because I'm working on the new website of a webradio and I've a problem, I want to get info (like current title ) of the mp3 stream of the radio.

But I've no idea about how to do this ...

The stream is hosting by infomaniak.

This the url : http://radiomed.ice.infomaniak.ch/radiomed.mp3

Can you help me ?

P.S.: Sorry for my english , I'm french .

outstore
  • 175
  • 2
  • 13

1 Answers1

0

You can use some tools like ffmpeg to get metadata in stream.

ffmpeg -i http://radiomed.ice.infomaniak.ch/radiomed.mp3 -f ffmetadata metadata.txt

Otherwise you can read the StreamTitle metadata directly inside packets.

Example in PHP :

$handle = fopen('http://radiomed.ice.infomaniak.ch/radiomed.mp3', 'r');
while (!feof($handle)) {
  // Get 1000 bytes per 1000 bytes
  $buffer = stream_get_contents($handle, 1000);
  // Check if StreamTitle is present in it
  if (strpos($buffer, 'StreamTitle=')!==false) {
    // Slice StreamTitle to get title and artist
    $title = explode('StreamTitle=', $buffer)[1];
    return substr($title, 1, strpos($title, ';') - 2);
   }
 }

Tips : Add context in fopen function if user agent is required or if you have redirection.