【问题标题】:unable to get metadate title on hebrew (get it on gibberish)无法在希伯来语中获得元日期标题(在胡言乱语中获得)
【发布时间】:2020-04-24 12:17:46
【问题描述】:

我正在开发安卓应用程序

在编写代码以获取“正在加载”的流媒体标题时,我无法在希伯来语中收到标题

但我收到了他的胡言乱语

如果有人能帮我解决这个问题,我会很高兴的 enter image description here

    @Override
    protected IcyStreamMeta doInBackground(URL... urls)
    {
        try
        {
            streamMeta.refreshMeta();
            Log.e("Retrieving MetaData","Refreshed Metadata");
        }
        catch (IOException e)
        {
            Log.e(MetadataTask2.class.toString(), e.getMessage());
        }
        return streamMeta;
    }

    @Override
    protected void onPostExecute(IcyStreamMeta result)
    {
        try
        {
            title_artist=streamMeta.getTitle();
            Log.e("Retrieved title_artist", title_artist);
            if(title_artist.length()>0)
            {
                textView.setText(title_artist);
            }
        }
        catch (IOException e)
        {
            Log.e(MetadataTask2.class.toString(), e.getMessage());
        }
    }
}

class MyTimerTask extends TimerTask {
    public void run() {
        try {
            streamMeta.refreshMeta();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            String title_artist=streamMeta.getTitle();
            Log.i("ARTIST TITLE", title_artist);
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}

}

【问题讨论】:

  • 添加代码和避免粘贴链接的要求是有原因的。绕过它们只会让你的问题结束。请张贴Minimal, Reproducable Example,而不是链接到很多代码。

标签: java android url stream hebrew


【解决方案1】:

看起来IcyMetaData 只是将原始字节转换为char(有效地执行 ISO-8859-1 编码,而不是使用检测服务器发送的任何内容)line 149

metaData.append((char) b);

如果不修补/修复 IcyMetaData 类,我看不到解决此问题的方法。

【讨论】:

  • 所以我必须改变这个类?
  • 是的,它可能需要将InputStream 包装在InputStreamReader 中并提供正确的编码。 或者编码是明确指定的(可能是 UTF-8),或者通过 HTTP 标头进行通信,但我不知道它在这里是哪一个。
猜你喜欢
  • 1970-01-01
  • 2012-06-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多