在Android App中显示来自Icecast服务器的元数据 [英] Display Metadata from icecast server in Android App

查看:65
本文介绍了在Android App中显示来自Icecast服务器的元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从一台icecast流服务器中获取元数据信息,并在我的Android应用程序中显示此类数据.有什么建议吗?

I want to get the metadata information from one of icecast streaming servers and display such data in my Android Application. Any recommendation?

使用下面的代码,我无法获取完整的元数据(艺术家和标题....)

using the below code , I am not able to get the full metadata ( artist and the title ....)

代码

String  stringUrl="http://dev.kigen.co:8000/xrm-ele.opus";

URL url = null;
try {
    url = new URL(stringUrl);
} catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
URLConnection cn = null;
try {
    cn = url.openConnection();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}   
try {
    cn.connect();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}   

int pos=1;
String x;
String y;

while (cn.getHeaderField(pos) != null) { 
    x=cn.getHeaderFieldKey(pos); 
    y = cn.getHeaderField(x); 
    System.out.println(":::::"+""+x+" : "+y); 
    pos++; 
}

}

生成的输出

:::::Server : Steamcast Distributed Network Media Server/1.0.0 decennium (Windows 64-bit)
:::::Date : Sat, 24 Oct 2015 16:52:16 GMT
:::::Connection : Keep-Alive
:::::Content-Type : application/ogg
:::::Cache-Control : max-age=0, no-cache, no-store
:::::Expires : Mon, 25 Jan 2002 10:11:57 GMT
:::::Pragma : no-cache
:::::ice-name : [XRM] - Electronic
:::::ice-genre : Electronic, Dance, Trance
:::::ice-url : http://www.xrm.fm/
:::::ice-public : 1
:::::ice-bitrate : 64
:::::ice-description : XRM Electronic in OGG Opus
:::::ice-audio-info : 
:::::Transfer-Encoding : chunked
:::::Set-Cookie : __steam_sess=8134e975470ac65a-5edd5a42-4a1b-6f58-87d4e64dc919bc08fb1821b0; path=/

推荐答案

我看到您正在使用我的Steamcast服务器.这不是Icecast,因此有点不同.但是,最大的问题是您正在使用Opus流.这些是OGG封装的流.您可以尝试使用 android.media.MediaMetadataRetriever 来检索元数据.不同版本的Android具有不同的功能.因此,它可能无法在所有版本上正常工作.

I see your using my Steamcast server. This is not Icecast and as such is a bit different. However, the biggest problem is you are using an Opus stream. These are OGG encapsulated streams. You could try using android.media.MediaMetadataRetriever to retrieve the metadata. Different version of Android have different capabilities. So it might not work correctly on all versions.

这篇关于在Android App中显示来自Icecast服务器的元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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