Android Media Player RTSP

前端 未结 1 1625
夕颜
夕颜 2021-02-10 14:03

I\'m trying to watch RTSP streaming on Android device. But if the server set password for the streaming my Android cannot play it. If without password it\'s ok. Here is my codes

相关标签:
1条回答
  • 2021-02-10 14:45

    I'm developing the RTSP related code just like you, and I found the following conclusions:

    1. When using MediaPlayer, your RTSP_URL can be like: rtsp://account:pass@192.168.0.x
    2. But with the authentication you mentioned, if your camera use HTTP basic auth, you need to add header in http request:, ex(I use OKHTTP 2.0):

      String basicAuth = Credentials.basic("account", "pass"); Request request = new Request.Builder().url(url).header("Authorization", basicAuth).build(); Response response = client.newCall(request).execute();

    That works for me! Hope it's helpful for you.

    0 讨论(0)
提交回复
热议问题