如何获得音频流与元数据的MediaPlayer? [英] How to get streaming audio metadata with MediaPlayer?

查看:373
本文介绍了如何获得音频流与元数据的MediaPlayer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个电台播放器,我需要检索和实时音频流更新元数据。

I'm building a radio player and I need to retrieve and update the metadata from the audio stream in real time.

我试着 MediaMetadataRetriever 但得到空值:

MediaMetadataRetriever mmr;

url = "http://stream0.wfmu.org/freeform-128k";

if (Build.VERSION.SDK_INT >= 14)
    mmr.setDataSource(url, new HashMap<String, String>());
else
    mmr.setDataSource(url);

String out = "";
out += mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
out += "\n";
out += mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
out += "\n";
out += mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM);
out += "\n";
out += mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_YEAR);
out += "\n";

怎么了?

和我怎么能知道元数据的变化是什么时候?使用 OnInfoListener onInfo ?它对付我感兴趣的(艺术家,标题......)或轨道的类型或语言code,如 MediaPlayer.TrackInfo 的元数据?

And how can I know when the metadata changes? Using OnInfoListener's onInfo? Does it deal with the metadata I'm interested in (artist, title...) or the type or language code of the track, like MediaPlayer.TrackInfo?

推荐答案

您试图访问元数据是通过SHOUTcast服务器交付(第2版)。 MediaMetadataRetriever不支持Shoutcast一样元数据检索,所以你将不能够使用的。据我所知,有一些支持Shoutcast一样版本的2元数据检索,所以你需要写code自己没有基于Java库。请参阅指南这里获取更多信息。

The metadata you are trying to access is a delivered via a SHOUTcast server (version 2). MediaMetadataRetriever doesn't support SHOUTcast metadata retrieval so you won't be able to use that. To my knowledge, there are no Java based libraries that support retrieval of SHOUTcast version 2 metadata so you will need to write the code yourself. See the guide here for more information.

这篇关于如何获得音频流与元数据的MediaPlayer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆