refactoring

This commit is contained in:
Roland Gruber 2020-07-30 20:41:39 +02:00
parent 2ee58dd737
commit df0e02da9f
1 changed files with 7 additions and 5 deletions

View File

@ -947,11 +947,12 @@ window.lam.tools.webcam.init = function() {
if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) { if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
navigator.mediaDevices.enumerateDevices() navigator.mediaDevices.enumerateDevices()
.then(function(mediaDevices) { .then(function(mediaDevices) {
mediaDevices.forEach(mediaDevice => { for (var i = 0; i < mediaDevices.length; i++) {
var mediaDevice = mediaDevices[i];
if (mediaDevice.kind === 'videoinput') { if (mediaDevice.kind === 'videoinput') {
contentDiv.show(); contentDiv.show();
} }
}); };
}); });
} }
}; };
@ -1064,9 +1065,10 @@ window.lam.tools.webcam.prepareData = function() {
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight); context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
var canvasData = canvas.toDataURL("image/png"); var canvasData = canvas.toDataURL("image/png");
video.pause(); video.pause();
window.lam.tools.webcamStream.getTracks().forEach(function(track) { var tracks = window.lam.tools.webcamStream.getTracks();
track.stop(); for (var i = 0; i < tracks.length; i++) {
}); tracks[i].stop();
}
jQuery(canvas).hide(); jQuery(canvas).hide();
jQuery(video).hide(); jQuery(video).hide();
return canvasData; return canvasData;