SHOUTcast Radio Streaming不适用于Kitkat

时间:2014-07-21 05:03:53

标签: android audio stream streaming audio-streaming

https://play.google.com/store/apps/details?id=com.sirius.fm.radio这是我的申请网址。

其中我正在播放来自shout演员的音频,它工作正常,直到android发布kitkat更新,最近我遇到问题当我在android kitkat上运行应用程序时,它没有在kitkat OS版本中流式传输

这是我正在使用的流式网址

http://s8.voscast.com:7112

这是错误日志我正在使用kitkat版本

07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425): Unable to initialize the MediaPlayer for fileUrl=http://s8.voscast.com:7112
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425): java.net.ProtocolException: Unexpected status line: ICY 200 OK
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.android.okhttp.internal.http.RawHeaders.setStatusLine(RawHeaders.java:108)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.android.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:308)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:135)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:644)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:347)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.sirius.fm.radio.StreamingMediaPlayer.downloadAudioIncrement(StreamingMediaPlayer.java:117)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.sirius.fm.radio.StreamingMediaPlayer$startRadio.doInBackground(StreamingMediaPlayer.java:88)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at com.sirius.fm.radio.StreamingMediaPlayer$startRadio.doInBackground(StreamingMediaPlayer.java:1)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
07-17 06:15:22.911: E/com.sirius.fm.radio.StreamingMediaPlayer$startRadio(1425):    at java.lang.Thread.run(Thread.java:841)
07-17 06:15:22.941: E/on post exte(1425): post exte

在所有其他版本的Android中,例如Micromax Canvas 4 A210Samsung Galaxy s3等。其中没有kitkat版本,它可以正常工作。

在kitkat设备中,Lg OptimusNexus 5Nexus 4它不起作用,显示错误

任何帮助/指南都将不胜感激。

谢谢你

1 个答案:

答案 0 :(得分:1)

最后我得到了解决方案

我将以下方法替换为新方法

URLConnection cn = new URL(mediaUrl).openConnection();
        cn.setRequestProperty("Icy-metadata", "1");
        cn.connect();
        InputStream stream = cn.getInputStream();
        if (stream == null) {
            Log.e(getClass().getName(),"Unable to create InputStream for mediaUrl:" + mediaUrl);
        }

用下面描述的新方法替换上述方法

final int CONNECT_TIMEOUT_MILLIS = 60 * 1000; // 30s
              final int READ_TIMEOUT_MILLIS = 85 * 1000; // 45s

         OkHttpClient client = new com.squareup.okhttp.OkHttpClient();
            client.setConnectTimeout(CONNECT_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
            client.setReadTimeout(READ_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
           OkUrlFactory okUrlFact= new OkUrlFactory(client);

        HttpURLConnection con=   okUrlFact.open(new URL(mediaUrl) );
        con.setRequestProperty("Icy-metadata", "1");
        con.connect();

希望它会帮助一些人

由于