problem in streaming audio from https link

前端 未结 2 2121
忘掉有多难
忘掉有多难 2021-02-11 02:18

Hi everyone I\'m a bit new to android I have developed an app which is streaming the audio from server everything was going fine until my app crashed, I debugged it and found ou

2条回答
  •  星月不相逢
    2021-02-11 03:02

    Just add below code before calling mediaplayer

    KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
            trustStore.load(null, null);
            MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
            sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
            sf.fixHttpsURLConnection();
            HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
            HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
    

    MySSLSocketFactory: https://github.com/joniks/Android-Async-HTTP/blob/master/library/src/main/java/com/loopj/android/http/MySSLSocketFactory.java

提交回复
热议问题