87,990
社区成员
发帖
与我相关
我的任务
分享<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
<script src="jquery.webcam.js"></script>
</head>
<body>
<div id="webcam"></div>
<div id="avatar_priview" style="width: 320px"></div>
<input type="button" onclick=" webcam.capture();" value="拍照"/>
<script>
jQuery("#webcam").webcam({
width: 320,
height: 240,
mode: "save",
swffile: "jscam_canvas_only.swf", // canvas only doesn't implement a jpeg encoder, so the file is much smaller
onTick: function(remain) {
if (0 == remain) {
jQuery("#status").text("Cheese!");
} else {
jQuery("#status").text(remain + " seconds remaining...");
}
},
onSave: function(data) {
var col = data.split(";");
alert(data);
console.info(data);
// Work with the picture. Picture-data is encoded as an array of arrays... Not really nice, though =/
},
onCapture: function () {
webcam.save();
// Show a flash for example
},
debug: function (type, string) {
// Write debug information to console.log() or a div, ...
console.log(type+":"+string);
},
onLoad: function () {
// Page load
var cams = webcam.getCameraList();
for(var i in cams) {
jQuery("#cams").append("<li>" + cams[i] + "</li>");
}
}
});
</script>
</body>
</html>