Roman Semko
Roman Semko

Reputation: 1601

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!

Upvotes: 13

Views: 23731

Answers (2)

TBR
TBR

Reputation: 2880

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.

Upvotes: 2

Brad
Brad

Reputation: 163234

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:

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.

Upvotes: 7

Related Questions