-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcontroller.js
67 lines (65 loc) · 2.05 KB
/
controller.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
(function() { 'use strict';
angular.module('webcam').controller('webcamController', webcamController);
webcamController.$inject = ['$scope', '$log'];
function webcamController($scope, $log) {
/* jshint validthis: true */
var vm = this;
vm.config = {
delay: 1,
shots: 3,
countdown : 3,
flashFallbackUrl: 'vendors/webcamjs/webcam.swf',
shutterUrl: 'shutter.mp3',
flashNotDetectedText: 'Seu browser não atende os requisitos mínimos para utilização da camera. ' +
'Instale o ADOBE Flash player ou utilize os browsers (Google Chrome, Firefox ou Edge)'
};
vm.showButtons = false;
vm.captureButtonEnable = false;
vm.progress = 0;
vm.onCaptureComplete = function(src) {
$log.log('webcamController.onCaptureComplete : ', src);
vm.progress = 100;
var el = document.getElementById('result');
var img = document.createElement('img');
img.src = src[vm.config.shots-1];
img.width = 240;
img.height = 180;
el.appendChild(img);
};
vm.onError = function(err) {
$log.error('webcamController.onError : ', err);
vm.showButtons = false;
};
vm.onLoad = function() {
$log.info('webcamController.onLoad');
vm.showButtons = true;
};
vm.onLive = function() {
$log.info('webcamController.onLive');
vm.captureButtonEnable = true;
};
vm.onCaptureProgress = function(src, progress) {
vm.progress = progress;
var result = {
src: src,
progress: progress
}
var el = document.getElementById('result');
var img = document.createElement('img');
img.src = src;
img.width = 240;
img.height = 180;
el.appendChild(img);
$log.info('webcamController.onCaptureProgress : ', result);
};
vm.capture = function() {
$scope.$broadcast('ngWebcam_capture'); };
vm.on = function() {
$scope.$broadcast('ngWebcam_on');
};
vm.off = function() {
$scope.$broadcast('ngWebcam_off');
vm.captureButtonEnable = false;
};
}
})();