title: HTML5 video for iPhone / iPad. How to detect connection speed?
body: <p>I need to stream a video in Safari for iPhone/iPad with the best possible quality.</p>
  
  <p>I created 2 video files: one in low-quality for slow 3G speed, one in hi-quality for WiFi broadband streaming. I noticed that some apps (YouTube for example) are able to detect if the mobile device is running by 3G or WiFi, and so select a small sized video rather than an hi-quality video.</p>
  
  <p>Now that is my DOM / Javascript code, the <em>$v</em> value is replaced by <em>PHP</em> and contains the video filename:</p>
  
  <pre><code>&lt;video id="thevideo" src="streaming/video_&lt;?=$v ?&gt;.m4v" width="600" height="360" width="640" height="360" preload="preload" controls="controls" autoplay="autoplay"&gt;
  flowplayer/video&lt;?=$v ?&gt;.m4v
  &lt;/video&gt;    
  
  &lt;script type="text/javascript"&gt;
  var myvideo = document.getElementById("thevideo");
  
  myvideo.load();
  myvideo.play();
  &lt;/script&gt;
  </code></pre>
  
  <p>Can I write something in Javascript / Webkit that is able to detect the connection mode? </p>
  
  <p>Thanks to all.</p>