HTML5 video for iPhone / iPad. How to determine the connection speed?

I need streaming video in Safari for iPhone / iPad with the best quality.

I created 2 video files: one in low quality for slow 3G speed, one in high speed Wi-Fi broadband. I noticed that some applications (e.g. YouTube) can determine if a 3G or Wi-Fi mobile device is working, and therefore choose small video rather than high quality video.

Now this is my DOM / Javascript code, the value of $ v is replaced by PHP and contains the video file name:

<video id="thevideo" src="streaming/video_<?=$v ?>.m4v" width="600" height="360" width="640" height="360" preload="preload" controls="controls" autoplay="autoplay">
flowplayer/video<?=$v ?>.m4v
</video>    

<script type="text/javascript">
var myvideo = document.getElementById("thevideo");

myvideo.load();
myvideo.play();
</script>

Can I write something in Javascript / Webkit able to detect connection mode?

Thanks to everyone.

+1
source share
2 answers
  • , :

Apple Reachability, UIWebView. URL- , :

//determine the connection type via Reachability

myURLString = [myURLString stringByAppendingString:[NSString stringWithFormat:@"?conntype=%@", *connTypeString]];

//then send the request for the page.

URL- PHP, URL- , .

  • , Javascript PHP script.

: http://jan.moesen.nu/code/php/speedtest/index.php?numKB=512

+2
+3

All Articles