You seem to use a different method for streaming and I don't know about that one, but this is a rather simple task if you use libvlc's MediaPlayer
for playing remote streams.
The Media
object used by MediaPlayer
can have EventListeners set. One event type is Media.Event.MetaChanged
, which triggers at song changes where new metadata is sent by the server:
mLibVLC = new LibVLC();
mMediaPlayer = new MediaPlayer(mLibVLC);
Media media = new Media(mLibVLC, "http://82.196.0.163:8000/dj.ogg");
media.setEventListener(new Media.EventListener() {
@Override
public void onEvent(Media.Event event) {
if (event.type == Media.Event.MetaChanged) {
//New metadata received
Media media = mMediaPlayer.getMedia();
String songMetadata = media.getMeta(Media.Meta.NowPlaying);
}
}
});
mMediaPlayer.setMedia(media);
mMediaPlayer.play();
Keys other than NowPlaying
also exist, but every IceCast server I worked with so far only delivered that one, with data consisting of artist and song title together as a single string.