admin管理员组文章数量:1425195
I have 3 types of video:
- 720x720,
- 480x480 and
- 320x320.
How to select automatically quality of video depending on network throughput of the user?
I have 3 types of video:
- 720x720,
- 480x480 and
- 320x320.
How to select automatically quality of video depending on network throughput of the user?
Share Improve this question edited Jul 15, 2014 at 10:43 Artjom B. 62k26 gold badges135 silver badges230 bronze badges asked Feb 17, 2014 at 2:03 user3311412user3311412 1172 silver badges7 bronze badges 5- related: stackoverflow./q/8221509/218196 – Felix Kling Commented Feb 17, 2014 at 2:09
- @FelixKling 404 (Page Not Found) Error – user3311412 Commented Feb 17, 2014 at 2:11
- Yeah well, that's the problem with links... :-/ – Felix Kling Commented Feb 17, 2014 at 2:13
- the site at all doesn't work. =(( – user3311412 Commented Feb 17, 2014 at 2:15
- @user3311412 Archived version here. – Substantial Commented Feb 17, 2014 at 8:48
1 Answer
Reset to default 7Step 1
Upload an image around size of 1Mb somewhere on your server. You must know exact size of image in bytes and image's URL.
Step 2
var imageAddr = "IMAGE_URL_HERE";
imageAddr += "?n="+Math.random();
var startTime, endTime;
var downloadSize = SIZE_OF_IMAGE_IN_BYTES;
var download = new Image();
download.onload = function () {
endTime = (new Date()).getTime();
showResults();
}
startTime = (new Date()).getTime();
download.src = imageAddr;
function showResults() {
var duration = (endTime - startTime) / 1000; //Math.round()
var bitsLoaded = downloadSize * 8;
var speedBps = (bitsLoaded / duration).toFixed(2);
var speedKbps = (speedBps / 1024).toFixed(2);
var speedMbps = (speedKbps / 1024).toFixed(2);
if(speedMbps<1){
//LOAD_SMALL_VIDEO
}
else if(speedMbps<2){
//LOAD_MEDIUM_VIDEO
}
else {
//LOAD_LARGE_VIDEO
}
}
本文标签: javascriptAuto select appropriate video quality depending upon network bandwidthStack Overflow
版权声明:本文标题:javascript - Auto select appropriate video quality depending upon network bandwidth? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745371830a2655764.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论