如何获得SHOUTcast的“正在播放"流中的元数据? [英] How do I obtain SHOUTcast "now playing" Metadata from the stream?

查看:60
本文介绍了如何获得SHOUTcast的“正在播放"流中的元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,我要查询有关流" http://streaming.shoutcast.com的当前广播./80sPlanet "(在线广播电台"A.0.0.00Radio:所有时间都是80年代").我可以通过将标头"icy-metadata"设置为"1"来对此URL进行HTTP GET请求,它返回包括以下标头"icy-*":

Say, I am about to inquire about current broadcasting of the stream "http://streaming.shoutcast.com/80sPlanet" (online radio "A.0.0.00Radio:All 80s All The Time"). I can make a HTTP GET requist to this URL with header "icy-metadata" set to "1", and it returns including the following "icy-*" headers:

key = "icy-br"; value = "128"
key = "icy-genre"; value = "Decades,80s"
key = "icy-metaint"; value = "16000"
key = "icy-name"; value = "A.0.0.00Radio:All 80s All The Time"
key = "icy-notice1"; value = "<BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>"
key = "icy-notice2"; value = "SHOUTcast DNAS/posix(linux x64) v2.5.1.725<BR>"
key = "icy-pub"; value = "1"
key = "icy-sr"; value = "44100"
key = "icy-url"; value = "http://a.0.00radio.com/80s/"

但是没有有关流中当前正在播放的内容的信息(我的意思是歌曲/艺术​​家/专辑/等).不过,在信息流首页上( http://80splanet.com )总是有最新信息.有人告诉我,可以通过HTTP GET请求在流URL上添加"/7.html"或"/stats"来获取正在播放"信息.它适用于某些流.例如:

But there is no info about what is currently broadcasting on the stream (I mean song/artist/album/etc). Though, on the stream homepage (http://80splanet.com) there is always up-to-date information. I've been told that it is possible to get the "now playing" info by HTTP GET request to the stream URL adding "/7.html" or "/stats". And it works for some streams. For example:

http://198.100.125.242/7.html
<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>383,1,541,30000,377,128,Man of the Hour - w/ Patrick and Sebastian </body></html>

(数字是流统计信息.它们在SHOUTcast服务器文档中进行了说明)但是大多数流不支持此功能(不支持"/7.html"或"/stats").HTTP错误404返回或类似.

(The numbers are the stream statistics. They are explained in the SHOUTcast server documentation) But most of the streams do not support this feature (not "/7.html" nor "/stats"). HTTP error 404 returns or similar.

SHOUTcast似乎提供了一些API(wiki.shoutcast.com/wiki/SHOUTcast_Developer)来请求其电台目录,获取热门电台排行榜等.还有"SHOUTcast XML元数据规范".似乎有一种方法可以以某种方式从流中获取该元数据.

It looks like SHOUTcast provides some API (wiki.shoutcast.com/wiki/SHOUTcast_Developer) to request it's Radio Catalog, get Top Stations Charts and so on. There is also "SHOUTcast XML Metadata Specification". And it seems that there is a way to get that Metadata from the stream somehow.

此外,还有一种方法可以在"icy-metaint"标头值的基础上深入研究流原始数据并搜索元数据,如下所述:stackoverflow.com/a/4914538/8128293,但是(第一种)我无权访问流的原始数据(android.media.MediaPlayer类仅接收流URL并维护其内部的连接).(第二)我不确定这种方法,因为它在任何地方都没有记录.还有(第三点)我不确定它是否可以与非mpeg音频流一起使用(例如:audio/aacp).

Also, there is a way to dig into the stream raw data and search for the metadata basing on the "icy-metaint" header value as it explained here: stackoverflow.com/a/4914538/8128293, but (first) I have no access to the raw data of the stream (the android.media.MediaPlayer class recieves only the stream URL and maintain connection within itself). (Second) I am not sure about this approach due it is not docummented anywhere. And (third) I'm not sure if it would work with non-mpeg audio streams (for ex: audio/aacp).

我还听说有一种方法可以通过JSON请求将这种元数据获取到流,但是仍然没有示例可以查看.

Also I heard that there is a way to get this kind of metadata via JSON request to the stream, but still have no example to look at.

推荐答案

但是(首先)我无权访问流的原始数据(android.media.MediaPlayer类仅接收流URL并保持其内部的连接)

but (first) I have no access to the raw data of the stream (the android.media.MediaPlayer class recieves only the stream URL and maintain connection within itself)

您将必须请求流数据并自己从中解复用元数据.内置的Android类不会关心带内元数据.

You're going to have to request the stream data and demux the metadata from it yourself. The built-in Android classes aren't going to care about in-band metadata.

我不是Android开发人员,但看起来您可以创建自己的MediaDataSource. https://developer.android.com/reference/android/media/MediaDataSource.html

I'm no Android developer, but it looks like you can make your own MediaDataSource. https://developer.android.com/reference/android/media/MediaDataSource.html

(第二个)我不确定这种方法,因为它在任何地方都没有记录.

(Second) I am not sure about this approach due it is not docummented anywhere.

这是 方法,是唯一可行的方法.20年来没有改变.Icecast服务器也支持容器中的元数据,但这与您要执行的操作无关.

It's the approach, the only reasonable way to do it. It hasn't changed in 20 years. Icecast servers support metadata in the container as well, but that's unrelated to what you're trying to do.

(第三点)我不确定它是否适用于非mpeg音频流(例如:audio/aacp).

And (third) I'm not sure if it would work with non-mpeg audio streams (for ex: audio/aacp).

效果很好.它与内容类型完全无关.这种ICY样式的元数据处理不知道或不关心其嵌入的内容.在编解码器处理流之前,应将元数据从流中分离出来.

It works great. It has absolutely nothing to do with the content type. This ICY-style metadata handling doesn't know or care about what it's embedded with. The metadata should be separated out from the stream before the stream is handled by the codec.

我还听说有一种方法可以通过JSON请求将这种元数据获取到流中

Also I heard that there is a way to get this kind of metadata via JSON request to the stream

没有.至少,如果要与那里的所有服务器兼容,则不是.

There isn't. At least, not if you want to be compatible with all the servers out there.

但是,在流首页( http://80splanet.com )上总是有最新信息信息.

Though, on the stream homepage (http://80splanet.com) there is always up-to-date information.

有很多方法可以做到这一点.大多数每个站都使用自己的系统进行带外处理.(几乎有任何方法可以管理您的音乐库并处理调度.通常是从Web脚本实际驱动编码器元数据,在播放脚本时,正在播放"的数据库会实时更新,这是实时的.)一种方法是使用您链接到的答案中的方法来获取元数据服务器端.我曾经提供过可以做到这一点的API服务器.(如果您想从我这里获得许可,我仍然有代码.请给我发电子邮件至brad@audiopump.co.)一种现代的方法是使用MediaSource Extensions并处理浏览器中的元数据解复用,然后再将流传递给玩家.SHOUTcast和Icecast均不支持此功能,因为它们均未正确支持CORS.我自己的CDN支持此方法,该代码也可用于许可.

There are lots of ways to do this. Most every station does this out-of-band with their own system. (There's almost any way to manager your music library and handle scheduling. It's common to actually drive the encoder metadata from a web script, where your "now playing" database is updated in real time at the time of playback into the encoder.) Another way is to get the metadata server-side using the methods in the answer you linked to. I used to offer an API server that would do this. (I still have the code, if you want to license it from me. E-mail me at brad@audiopump.co.) A modern way is to use MediaSource Extensions and handle the metadata demuxing in-browser before passing the stream off to the player. Neither SHOUTcast nor Icecast support this as neither properly supports CORS. My own CDN supports this method, and the code is available for licensing as well.

这篇关于如何获得SHOUTcast的“正在播放"流中的元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆