How do I extract streamed “now playing” data embedded in an Icecast audio (radio) stream on Samsung Smart-TV

霸气de小男生 提交于 2019-12-05 16:39:32

Shoutcast supports "Icy-MetaData" - an additional field in the request header. When set, its a request to the shoutcast server to embed metadata about the stream at periodic intervals(once every "icy-metaint" bytes) in the encoded audio stream itself. The value of "icy-metaint" is decided by the shoutcast server configuration and is sent to the client as part of the initial reply.

Check out this post on Shoutcast Internet Radio Protocol for details on icy:metadata and sample code in C.

A somewhat more technical discussion is also available at
http://forums.radiotoolbox.com/viewtopic.php?t=74

Brad

Yes, this is possible. The metadata is interleaved into the stream data at a specified interval. Basically, you read 8192 bytes (or whatever is specified by the Icy-MetaInt response header), and then you read the metadata block.

The first byte of that metadata block tells you the length of the data. A length of 0 means there is no updated metadata.

Once you read the meta block, then you go back to reading stream data.

I have all of this in more detail on my answer here: https://stackoverflow.com/a/4914538/362536 While I know you're not writing PHP, the principal is identical no matter what language.

From native player there is no option to get this meta.

You could probably use jQuery.stream plugin to fetch the meta directly - but you need to setup Access-Control-Allow-Origin on you icecast server - but I have no idea if it will work.

The best solution here will be to use this script: http://code.google.com/p/icecast-now-playing-script/

So you install this script on your web server and from the SmartTV application you will AJAX it once for a while, while your stream is playing.

I just created a radio player for icecast and centova, it uses lastFM api to extract the song meta data. https://github.com/johndavedecano/Icecast-Centova-LastFM-API

If you are doing this for a radio station, then they can provide this data through the XSLT feature of Icecast. Some random old XSLT examples for offering stream metadata that I did at some point.

The other option is to run Icecast 2.4.1 or add the two files (xml2json.xsl status-json.xsl) to an old version.

Note that only Icecast 2.4.1 or newer supports adding CORS/ACAO headers that might be necessary to access data from a web app / web site.

If you are not directly cooperating with the radio station and can't ask them to do this, then disregard this answer. Someone else might find it useful though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!