MediaMetadataRetriever in a streaming source

I find it difficult to display the current track being played from the streaming source. Using the MediaMetaDataRetriever class returns NULL, which means it failed. I wrote a simple method, but now I am inclined to think that this only works in media files such as MP3, WMA, AVI, etc.

public void metaData(){
        mmr.setDataSource(urlStation);
        String metaD = mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST);
        Toast.makeText(MainActivity.this, "Artist = " + metaD, Toast.LENGTH_LONG).show();

Any good and easy recommendations would be greatly appreciated. Thank you for your time!

+8
source share
3 answers

MediaMetadataRetriever does not work with the URL in some versions of Android, see this . I created FFmpegMediaMetadataRetriever as a workaround, I suggest trying it.

+11

, , setDataSource :

setDataSource(String uri, Map<String, String> headers)

, ,

public void getStreamMetaData(String url){
  MediaMetadataRetriever mmr = new MediaMetadataRetriever();
  mmr.setDataSource(url, new HashMap<String, String>());
  //now do whatever you want

}

mp4, . , setDataSource AsyncTask , .

+5

:

public void setDataSource (String uri, Map<String, String> headers)

( URL- , setDataSource (" https://somewebsite.com/somefile.mp3 ", new HashMap<String,String>());)

0

All Articles