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/"
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>
(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.
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.
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).
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.
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)
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.
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.
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.
And (third) I'm not sure if it would work with non-mpeg audio streams (for ex: audio/aacp).
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.
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.
Though, on the stream homepage (http://80splanet.com) there is always up-to-date information.
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.