Index: ssts-web/src/main/webapp/disinfectsystem/test/takeVideoAndImg.js =================================================================== diff -u -r37881 -r37886 --- ssts-web/src/main/webapp/disinfectsystem/test/takeVideoAndImg.js (.../takeVideoAndImg.js) (revision 37881) +++ ssts-web/src/main/webapp/disinfectsystem/test/takeVideoAndImg.js (.../takeVideoAndImg.js) (revision 37886) @@ -105,8 +105,8 @@ } function openCamera() { - var cameraHeight = $(window).height()-$(".camera_footer").height()-20; - var cameraWidth = parseInt(cameraHeight/480*640); + var cameraHeight = $(window).height() - $(".camera_footer").height() - 20; + var cameraWidth = parseInt(cameraHeight / 480 * 640); var video = document.getElementById('video'); video.controls = false; @@ -189,24 +189,28 @@ } }; -function reloadUserMedia(width, height, isFirst){ +function reloadUserMedia(width, height, isFirst) { var video = document.getElementById("video"); var videoObj = { width: width, height: height } MediaUtils.getUserMedia(videoObj, false, function (err, stream) { if (err) { - if(err == 'OverconstrainedError'){ - if(width == 2048){ + if (err == 'OverconstrainedError') { + if (width == 4096) { + reloadUserMedia(2560, 1440, isFirst); + } else if (width == 2560) { + reloadUserMedia(2048, 1152, isFirst); + } else if (width == 2048) { reloadUserMedia(1920, 1080, isFirst); - }else if(width == 1920){ + } else if (width == 1920) { reloadUserMedia(1280, 720, isFirst); - }else if(width == 1280){ + } else if (width == 1280) { reloadUserMedia(640, 480, isFirst); - }else if(width == 640){ + } else if (width == 640) { reloadUserMedia(320, 240, isFirst); } return - }else { + } else { throw err; } } else { @@ -216,30 +220,45 @@ var settings = videoTrack.getSettings(); maxWidth = settings.width; maxHeight = settings.height; - canvasBig.setAttribute('width',maxWidth); - canvasBig.setAttribute('height',maxHeight); + canvasBig.setAttribute('width', maxWidth); + canvasBig.setAttribute('height', maxHeight); video.play(); - if(isFirst){ + if (isFirst) { var html = ''; - if(maxWidth == 2048){ + if (maxWidth == 4096) { html += ''; html += ''; html += ''; html += ''; + html += ''; + html += ''; + html += ''; + } else if (maxWidth == 2560) { + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + } else if (maxWidth == 2048) { + html += ''; + html += ''; + html += ''; + html += ''; html += ''; - }else if(maxWidth == 1920){ + } else if (maxWidth == 1920) { html += ''; html += ''; html += ''; html += ''; - }else if(maxWidth == 1280){ + } else if (maxWidth == 1280) { html += ''; html += ''; html += ''; - }else if(maxWidth == 640){ + } else if (maxWidth == 640) { html += ''; html += ''; - }else if(maxWidth == 320){ + } else if (maxWidth == 320) { html += ''; } $('#changeResolution').html(html); @@ -248,38 +267,42 @@ }); } -function changeResolutionValue(){ +function changeResolutionValue() { var width = $('#changeResolution').val(); - if(width == '2048'){ - reloadUserMedia(2048,1152); - }else if(width == '1920'){ - reloadUserMedia(1920,1080); - }else if(width == '1280'){ - reloadUserMedia(1280,720); - }else if(width == '640'){ - reloadUserMedia(640,480); - }else if(width == '320'){ - reloadUserMedia(320,240); + if (width == '4096') { + reloadUserMedia(4096, 2160); + } else if (width == '2560') { + reloadUserMedia(2560, 1440); + } else if (width == '2048') { + reloadUserMedia(2048, 1152); + } else if (width == '1920') { + reloadUserMedia(1920, 1080); + } else if (width == '1280') { + reloadUserMedia(1280, 720); + } else if (width == '640') { + reloadUserMedia(640, 480); + } else if (width == '320') { + reloadUserMedia(320, 240); } } // 这段代码主要是获取摄像头的视频流并显示在Video 签中 $(function () { - var cameraHeight = $(window).height()-$(".camera_footer").height()-20; - var cameraWidth = parseInt(cameraHeight/480*640); - $(".camera_wrapper").css({"height":cameraHeight+"px"}); + var cameraHeight = $(window).height() - $(".camera_footer").height() - 20; + var cameraWidth = parseInt(cameraHeight / 480 * 640); + $(".camera_wrapper").css({ "height": cameraHeight + "px" }); var canvas = document.getElementById("canvas"); var context = canvas.getContext("2d"); - if(showVideo == false || showVideo == 'false'){ + if (showVideo == false || showVideo == 'false') { $('.toggle_btn').hide(); } - if(hiddenImage == true || hiddenImage == 'true'){ + if (hiddenImage == true || hiddenImage == 'true') { $('.toggle_btn').hide(); $("#cameraBtn").addClass("on"); $("#takePhotos").prop("checked", false); $('#cameraTime').css('display', 'block'); openCamera(); - }else { + } else { $("#takePhotos").prop("checked", true);//默认选中拍照单选框 } @@ -292,7 +315,7 @@ */ var contextBig = canvasBig.getContext("2d"); - reloadUserMedia(2048, 1152, true); + reloadUserMedia(4096, 2160, true); // 这个是拍照按钮的事件, $("#cameraBtn").click(function () { @@ -392,18 +415,18 @@ $("#canvas").addClass("animate-bounce-up"); } } - + }); - + // 点击拍照单选框 $("#takePhotos").click(function () { if ($(this).prop("checked")) {//显示拍照图片 $("#cameraBtn").removeClass("on"); $("#cameraBtn").removeClass("stop"); $('#cameraTime').css('display', 'none'); $('#cameraTime').html('00:00'); - + second = 0; minute = 0; setTime('end');