1

With the the help of Create a videoplayer with the LibVLC for android, I succeeded to play online streaming from one of the icecast servers using vlclib in android application, but I am facing an issue now.

How can I retrieve the metadata like (song title , singer , album....etc) using vlcMediaPlayer object:

String url = "http://82.196.0.163:8000/dj.ogg";
LibVLC vlcMediaPlayer = VLCInstance.getLibVlcInstance();
vlcMediaPlayer.eventVideoPlayerActivityCreated(true);
vlcMediaPlayer.playMRL(url);
Community
  • 1
  • 1
techbrainless
  • 129
  • 2
  • 12

1 Answers1

0

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.

Şafak Gezer
  • 3,928
  • 3
  • 47
  • 49