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.)

Carl Veazey
  • 18,392
  • 8
  • 66
  • 81
Raghavendra
  • 101
  • 2
  • 2
    That is what HLS is designed for, no? You have to give files at different bitrates. so that you don't have to detect network conditions and it automatically changes the to low b/w versions automatically. Works for both web and device app streaming. – av501 Oct 05 '12 at 18:33

2 Answers2

1

Perhaps ifi_baudrate member of the if_data structure (declared in <net/if.h>) is what you need. If baudrate is less than some threshold value, then you can show an alert. Please see the following answer to know how to obtain the if_data structure for a particular network interface: https://stackoverflow.com/a/8014012/1310204

Community
  • 1
  • 1
Nikolay Mamaev
  • 1,474
  • 1
  • 12
  • 21
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 ;-)

Robert Hoffmann
  • 2,366
  • 19
  • 29