如何得知客户端从服务器的下载速度?
根据客户的下载速度,我想以低质量或高质量显示视频。 任何 Javascript 或 C# 解决方案都是可以接受的。
谢谢。
According to the client's download speed I want to show the video's either in low or high quality. Any Javascript or C# solution is acceptable.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
没有任何办法可以确定。 您只能测量向客户端发送数据的速度。 如果没有来自客户端的任何类型的输入来表明获取信息的速度有多快,您就无能为力。
您可以将客户端重定向到一个页面,该页面使用 javascript 下载页面中已知大小的元素。 然后,获取下载开始和结束时的时间,并将页面重定向到客户端上通过 javascript 构建的 URL,该 URL 会向您发送下载元素所花费的时间。
鉴于您知道元素的大小,您就可以估计速率并猜测下载速度。
There isn't any way to be sure. You can only measure how fast you can send data to the client. Without any kind of input from the client to indicate how fast it is getting the information, there isn't much you can do.
You could redirect the client to a page which uses javascript to download an element in the page which is of known size. Then, take the time at the beginning and at the end of the download and redirect the page to a URL constructed through javascript on the client which sends you the time it took to download the element.
Given that you know the size of the element, you can then estimate a rate and make a guess as to the download speed.
这是一篇帖子,介绍了 gmail 的工作原理以及它如何查找用户的互联网速度。 你可以获得一些想法。
Here is a post about how gmail works and how it finds the internet speed of the user. You can get some ideas.
也许,在 javascript 中,你可以做类似的事情:
未经测试的代码 - 但这个想法可能有效?
Maybe, in javascript, you can do something like:
untested code - but this idea might work?
大多数网站只是让用户选择高质量或低质量版本。
Most web sites simply let the user choose a high quality or low quality version.
这是一个坏主意,尤其是因为大多数用户可以自己控制带宽(即我正在运行使用大量带宽的 P2P 应用程序,但如果有其他需要优先处理的事情,我会关闭它们。)
This is a bad idea, not least because most users can control their bandwidth themselves (i.e. I'm running P2P apps that use significant bandwidth, but I turn them off if something else needs priority.)
您可以使用 Silverlight 或 Flash 作为上传 pugin。 这将使您能够在客户端上真正控制上传的内容、状态以及上传开始时的上传速度。
You could use Silverlight or Flash as upload pugin. This will enable you to have a real control on the client on what is uploaded, what the state is and what the upload speed is when the upload has been started.
您可以在 GeoIP Netspeed 中查找他们的地址: http://www.maxmind.com/app/geolocation< /a>
You could look up their address in GeoIP Netspeed: http://www.maxmind.com/app/geolocation