forked from sshilko/jQuery-AS3-Webcam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.html
78 lines (62 loc) · 1.96 KB
/
demo.html
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
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
<title>JS-Webcam demo</title>
</head>
<body>
<div id="webcam"></div>
<!-- see: mywebcam.js for configuration -->
<hr/>
<button id="takephoto">take photo</button>
<div id="result"></div>
<script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="webcam.js"></script>
<script>
//-------------------- custom event handlers
(function () {
$("#takephoto").hide();
webcam.onReady = function () {
$("#takephoto").show();
console.log('ready');
};
webcam.onError = function (e) {
switch (e.flag || false) {
case 'CAMNOTFOUND':
console.error('No webcam detected!');
break;
case 'CAMDISABLED':
console.warn('We need permission to access the webcam.');
break;
case 'NOFLASHPLAYER':
console.error('No up-to-date flash player installed. (min. 11.1.0)');
break;
default:
console.log('Webcam: unknown error.');
}
};
// take a photo and append img in result div
$("#takephoto").click(function () {
var result = webcam.save('window');
var img = new Image();
img.src = result;
$("#result").append(img);
});
})();
//-------------------- initialise the webcam
(function () {
var preLoaded = window.onload;
window.onload = function () {
if (typeof preLoaded == 'function') preLoaded();
//webcam.embed('webcam.swf', 500, 375, {
webcam.embed('webcam.swf', 640, 480, {
mirror: true,
smoothing: true,
framerate: 20,
shutterSound: 'shutter.mp3'
});
};
})();
</script>
</body>
</html>