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

孤街醉人 提交于 2019-12-07 11:43:33

问题


I am creating a Samsung TV app for a radio station and they provide the "Now Playing" info within the Icecast stream. Is it possible to (and how do I) extract this information?


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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




回答5:


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.



来源:https://stackoverflow.com/questions/12407248/how-do-i-extract-streamed-now-playing-data-embedded-in-an-icecast-audio-radio

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