Search code examples
javascriptaudioaudio-streamingaudiotrackinternet-radio

Retrieving the name of an audio track from a stream


I want to reproduce audio streams with the <audio> tag and display the name of the current track. To that end I have been using the audio's audioTracks property.

I know that this feature is experimental and I went out of my way to enable it.

In Epiphany ( Gnome Web ) the feature works flawlessly ( without even needing to enable it first ), but in Chrome and Firefox the AudioTrack's label property is always empty.

Is Chrome's and Firefox's implementation broken? Is there some other api I may use to retrieve the track's name?

How I am retrieving it:

document.getElementById('audio').audioTracks[0].label;

Solution

  • I've came across this library by Eshaz showing that is possible to retrieve meta data directly from the browser. But unfortunately CORS policies must be properly set to work.

    Like Brad pointed out, the best option is retrieve the information from the server side.

    Here hoping the AudioTrack feature turn mainstream in the near future. Thank you @Brad for all the help.