MediaMetadataRetriever on streaming source

自闭症网瘾萝莉.ら 提交于 2019-11-29 03:58:38

MediaMetadataRetriever doesn't work with URL's on certain versions of Android, see this issue. I created FFmpegMediaMetadataRetriever as a workaround, I suggest trying it out.

According to the same issue listed in the other answer, you just need to use the setDataSource method with these arguments:

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

So for example,

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

}

I tested it with a streaming mp4 and it worked for me. Also just a note, you'll want to use the setDataSource method in an AsyncTask or on another thread, since it may take a while to run according to the docs.

Ghassen KEFI

This method works better:

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

(with the url of your stream and an empty map e.g setDataSource("https://somewebsite.com/somefile.mp3", new HashMap<String,String>());)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!