Android - MediaPlayer 通过使用 IP 而不是地址开始播放得更快。为什么?
我正在使用 mediaPlayer.setDataSource 方法来设置 rtsp 流。它具有以下格式:
rtsp://X/vod/" + stringEncoded +"/mp4:" + music + ".mp4
事实证明,当我将直接 IP 放入 X 时,音乐将在大约 4 秒后开始播放。然而,当我输入地址时,需要15秒才能开始播放!
这不是 DNS 的问题,因为它可以立即解决地址问题,而且我还有一个使用相同地址的 iOS 应用程序,它可以立即运行。这可能是 Android 解释 DNS 返回的 IP 的方式存在问题。
我无法使用直接 IP,因为我必须平衡 DNS 中的请求(将每个请求发送到不同的计算机(不同的 IP))。
有人知道为什么当我使用地址而不是 IP 时 Android 需要更长的时间才能开始播放歌曲吗?
先感谢您!
I am using the mediaPlayer.setDataSource method to set a rtsp streaming. It has the following format:
rtsp://X/vod/" + stringEncoded +"/mp4:" + music + ".mp4
Turns out that when I put the direct IP in X, the music starts playing in about 4 seconds. However, when I put the address, it takes 15 seconds to start playing!
This is not a problem of DNS because it solves the address instantly and I also have an iOS application that uses the same address and it works instantly. This is probably some problem in how Android interprets the IP returned by the DNS.
I can't use the direct IP because I must balance the requests in the DNS (sending each request to a different machine (a different IP)).
Does anybody have any clue why android takes so much longer to start playing a song when I use the address instead of the IP?
Thank you in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终使用 java InetAddress 类获取 IP 并在 URL 中使用该 IP。这样就成功了。这是代码:
我仍然不知道为什么 setDataSource 方法会与地址混淆。
I ended up getting the IP using the java InetAddress class and using that IP in the URL. That way it worked. Here is the code:
I still have no idea why the setDataSource method messes up with the address though.