Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

html - HTML5 video for iPhone / iPad. How to detect connection speed?

I need to stream a video in Safari for iPhone/iPad with the best possible quality.

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.

Now that is my DOM / Javascript code, the $v value is replaced by PHP and contains the video filename:

<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 that is able to detect the connection mode?

Thanks to all.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You will have to load some sort of document to test your connection speed.

an example -- http://alexle.net/archives/257


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...