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
}
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745371831a4624828.html
评论列表(0条)