【问题标题】:Get html camera width and height获取html相机的宽度和高度
【发布时间】:2015-08-21 10:53:25
【问题描述】:
【问题讨论】:
标签:
html
video
capture
screen-size
【解决方案1】:
您可以使用loadedmetadata 事件来获取视频的高度和宽度。
video.addEventListener("loadedmetadata", function () {
find_video_size();
}, false);
function find_video_size(){
if (isStreaming++ <= 10) {
// videoWidth isn't always set correctly in all browsers
if (video.videoWidth > 0){
cwidth = video.videoWidth;
cheight = video.videoHeight;// / (video.videoWidth / cwidth);
$("#tutcanvas").attr("width", cwidth).attr("height", cheight);
isStreaming = 11;
}else{
setTimeout(find_video_size, 200);
}
}else{
$("#tutcanvas").attr("width", cwidth).attr("height", cheight);
}
}