8

Can anyone suggest how to handle a slow network when streaming video in a web view?

When the network strength is poor, a blank screen appears or video doesn't stream.

Is there a way to detect this condition so that we can alert the user? (Apart from using private API.)

4

2 回答 2

1

也许结构ifi_baudrate的成员if_data(在 中声明<net/if.h>)是您所需要的。如果波特率小于某个阈值,则可以显示警报。请参阅以下答案以了解如何获取if_data特定网络接口的结构: https ://stackoverflow.com/a/8014012/1310204

于 2012-10-25T03:55:01.267 回答
0

You can easily detect the state of the network connection via the HTML5 networking API http://www.html5rocks.com/en/mobile/optimization-and-performance/#toc-network-detection

Also if you want to test the network speed, just set up some files on your server of a specific size, and do a ajax request for the file, while timing how long it takes to download.

You can use a simple:

var start = new Date();

$.get("someFile.jpg")
     .done(function() {
              var elapsed = (new Date() - start);
     });

Or dig into the HTML5 performance API:

http://www.html5rocks.com/en/tutorials/webperformance/basics/

...if you not using javascript, the same applies. Just open a network connection with whatever is at your disposition, download a small file & do the math ;-)

于 2012-11-09T15:33:50.030 回答