Merge branch '1.11.x' of https://github.com/chamilo/chamilo-lms into 1.11.x
commit
6063767fe6
@ -0,0 +1,107 @@ |
|||||||
|
(function () { |
||||||
|
var config = { |
||||||
|
selectors: { |
||||||
|
btnFreeze: '#btnCapture', |
||||||
|
btnUnFreeze: '#btnClean', |
||||||
|
btnSave: '#btnSave', |
||||||
|
btnAuto: '#btnAuto', |
||||||
|
btnStop: '#btnStop', |
||||||
|
camera: '#chamilo-camera', |
||||||
|
results: '#upload_results' |
||||||
|
}, |
||||||
|
urlReceiver: '', |
||||||
|
video: { |
||||||
|
fps: 1000, |
||||||
|
maxTime: 60000, |
||||||
|
maxClip: 25 |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
function snap() { |
||||||
|
Webcam.snap(function (dataUri) { |
||||||
|
Webcam.upload(dataUri, config.urlReceiver, function (code, response) { |
||||||
|
$(config.selectors.results).html( |
||||||
|
'<h3>' + response + '</h3>' |
||||||
|
+ '<div>' |
||||||
|
+ '<img src="' + dataUri + '" class="webcamclip_bg">' |
||||||
|
+ '</div>' |
||||||
|
); |
||||||
|
}); |
||||||
|
}); |
||||||
|
}; |
||||||
|
|
||||||
|
var videoInterval = 0; |
||||||
|
|
||||||
|
function startVideo() { |
||||||
|
var counter = 0; |
||||||
|
videoInterval = window.setInterval(function () { |
||||||
|
counter++; |
||||||
|
|
||||||
|
window.setTimeout(function () { |
||||||
|
stopVideo(); |
||||||
|
}, config.video.maxTime); |
||||||
|
|
||||||
|
if (config.video.maxClip >= counter) { |
||||||
|
snap(); |
||||||
|
} else { |
||||||
|
stopVideo(); |
||||||
|
} |
||||||
|
}, config.video.fps); |
||||||
|
} |
||||||
|
|
||||||
|
function stopVideo() { |
||||||
|
if (!videoInterval) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
window.clearTimeout(videoInterval); |
||||||
|
} |
||||||
|
|
||||||
|
window.RecordWebcam = { |
||||||
|
init: function (params) { |
||||||
|
config = $.extend(true, config, params); |
||||||
|
|
||||||
|
$(document).on('ready', function () { |
||||||
|
Webcam.set({ |
||||||
|
width: 320, |
||||||
|
height: 240, |
||||||
|
image_format: 'jpeg', |
||||||
|
jpeg_quality: 90 |
||||||
|
}); |
||||||
|
Webcam.attach(config.selectors.camera); |
||||||
|
|
||||||
|
$('video').addClass('skip'); |
||||||
|
|
||||||
|
$(config.selectors.btnFreeze).on('click', function (e) { |
||||||
|
e.preventDefault(); |
||||||
|
|
||||||
|
Webcam.freeze(); |
||||||
|
}); |
||||||
|
|
||||||
|
$(config.selectors.btnUnFreeze).on('click', function (e) { |
||||||
|
e.preventDefault(); |
||||||
|
|
||||||
|
Webcam.unfreeze(); |
||||||
|
}); |
||||||
|
|
||||||
|
$(config.selectors.btnSave).on('click', function (e) { |
||||||
|
e.preventDefault(); |
||||||
|
|
||||||
|
snap(); |
||||||
|
}) |
||||||
|
|
||||||
|
$(config.selectors.btnAuto).on('click', function (e) { |
||||||
|
e.preventDefault(); |
||||||
|
|
||||||
|
startVideo(); |
||||||
|
}); |
||||||
|
|
||||||
|
$(config.selectors.btnStop).on('click', function (e) { |
||||||
|
e.preventDefault(); |
||||||
|
|
||||||
|
stopVideo(); |
||||||
|
}); |
||||||
|
}) |
||||||
|
} |
||||||
|
}; |
||||||
|
})(); |
||||||
@ -0,0 +1,42 @@ |
|||||||
|
<div class="row"> |
||||||
|
<div class="col-sm-6 text-center"> |
||||||
|
<h3>{{ 'LocalInputImage'|get_lang }}</h3> |
||||||
|
<div class="webcamclip_bg center-block"> |
||||||
|
<div id="chamilo-camera" class="embed-responsive-item"></div> |
||||||
|
</div> |
||||||
|
<form class="text-center"> |
||||||
|
<br/> |
||||||
|
<button id="btnCapture" class="btn btn-danger"> |
||||||
|
<span class="fa fa-camera" aria-hidden="true"></span> |
||||||
|
{{ 'Snapshot'|get_lang }} |
||||||
|
</button> |
||||||
|
<button id="btnClean" class="btn btn-success"> |
||||||
|
<span class="fa fa-refresh" aria-hidden="true"></span> |
||||||
|
{{ 'Clean'|get_lang }} |
||||||
|
</button> |
||||||
|
<button id="btnSave" class="btn btn-primary"> |
||||||
|
<span class="fa fa-save" aria-hidden="true"></span> |
||||||
|
{{ 'Save'|get_lang }} |
||||||
|
</button> |
||||||
|
|| |
||||||
|
<button id="btnAuto" class="btn btn-default"> |
||||||
|
{{ 'Auto'|get_lang }} |
||||||
|
</button> |
||||||
|
<button id="btnStop" class="btn btn-default"> |
||||||
|
{{ 'Stop'|get_lang }} |
||||||
|
</button> |
||||||
|
</form> |
||||||
|
</div> |
||||||
|
<div class="col-sm-6"> |
||||||
|
<div id="upload_results" class="center-block" style="background-color:#ffffff;"></div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<script> |
||||||
|
RecordWebcam.init({ |
||||||
|
urlReceiver: '{{ _p.web_main }}document/webcam_receiver.php?webcamname=' |
||||||
|
+ escape('{{ filename }}') + '&webcamdir={{ webcam_dir }}&webcamuserid={{ user_id }}', |
||||||
|
video: { |
||||||
|
maxClip: 10 |
||||||
|
} |
||||||
|
}); |
||||||
|
</script> |
||||||
Loading…
Reference in new issue