Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get Icecast metadata from HTML5 audio element?

I am using audio element to stream an ogg source from an icecast server. Does the audio element extract icy metadata and is there a way to access it through javascript?

Basically, I want to show "currently playing" information of a radio station I am streaming. What are my options?

Thanks!

like image 250
Roman Semko Avatar asked May 24 '11 19:05

Roman Semko


People also ask

How do I listen to Icecast?

Just navigate your web browser to host/port the Icecast server is listening on. If you are a Windows user, make sure you started the Icecast server and then click on the shortcut in the Startmenu, it will open the Icecast status page in your browser.

What is the difference between Shoutcast and Icecast?

Both provide better compression than MP3 without a reduction in audio quality. In the past Shoutcast provided AAC support, but this was discontinued in recent versions. Icecast supports several AAC and Ogg codecs, which means that your listeners have higher quality audio for the same amount of bandwidth.

Is Icecast open source?

Icecast was created in December 1998/January 1999 by Jack Moffitt and Barath Raghavan to provide an open-source audio streaming server that anyone could modify, use, and tinker with.

How does Icecast work?

A Source Client (i.e. IceS, RoarAudio, …) connects to a mountpoint on the Icecast server and sends audio or video data to it. Listeners connect to the mountpoint and Icecast send the stream to them. The Icecast server will be the place where all listeners of your stream will connect.


2 Answers

No, your HTML5 elements are only aware of the stream data, and aren't even making the appropriate request to fetch the metadata.

See these posts:

  • Developing the client for the icecast server

  • Pulling Track Info From an Audio Stream Using PHP

  • http://www.smackfu.com/stuff/programming/shoutcast.html

Now, this isn't impossible by any means. You just have to do it server-side. (See that second link in particular.)

I should also point out that on a full-blown SHOUTcast Server (haven't tested with Icecast, but its worth a try) generates "7.html" which contains data on the number of listeners, max listeners, peak listeners, stereo/mono, bitrate, and current track name as comma-separated values. Like this:

2,1,33,625,2,128,J Mascis - Not Enough

If you can fetch http://yourstreamingserver:port/7.html, then you can get this data very easily.

like image 105
Brad Avatar answered Sep 23 '22 12:09

Brad


In case of an Ogg container stream (So both Vorbis and Opus), at least Firefox supports javascript access to the metadata. This is currently only "vendor specific" Javascript API: audio.mozGetMetadata();

On the other hand if you go with Icecast 2.4.1 you can access metadata independently through a JSON API. Lack of synchronization as pointed out in other comments applies. It's usually "close enough" though.

like image 27
TBR Avatar answered Sep 22 '22 12:09

TBR