shooutcast广播流媒体不工作的奇巧



https://play.google.com/store/apps/details?id=com.sirius.fm.radio这是我的应用程序的url。

在其中我是流音频从呼喊cast,它工作得很好,直到android发布kitkat更新,最近我面临的问题,当我在android kitkat上运行应用程序,它不流广播在kitkat OS版本。

这是我的流url,我使用

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 A210, Samsung Galaxy s3等。它没有奇巧版本,它工作得很好。

而在kitkat设备如Lg Optimus, Nexus 5, Nexus 4它不工作,它显示上述错误

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

Thanks Any Way

终于有办法了

我用新的方法替换下面的方法

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();

希望它能帮助到一些人

谢谢

相关内容

  • 没有找到相关文章

最新更新