From c2c52b65e2b8a4be7dfcea04a296563c4bdf70a8 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Wed, 26 Sep 2012 19:02:25 +0200 Subject: [PATCH 01/13] Add pauseCamera and resumeCamera to allow camera pausing and resuming --- jquery.webcam.js | 11 ++++++++++- src/jscam.as | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/jquery.webcam.js b/jquery.webcam.js index ba9a945..b1c74a4 100644 --- a/jquery.webcam.js +++ b/jquery.webcam.js @@ -75,7 +75,16 @@ return cam.getCameraList(); } catch(e) {} } - + webcam.pauseCamera = function() { + try { + return cam.pauseCamera(); + } catch(e) {} + } + webcam.resumeCamera = function() { + try { + return cam.resumeCamera(); + } catch(e) {} + } webcam.onLoad(); } else if (0 == run) { webcam.debug("error", "Flash movie not yet registered!"); diff --git a/src/jscam.as b/src/jscam.as index aa70172..fdd018e 100644 --- a/src/jscam.as +++ b/src/jscam.as @@ -74,6 +74,9 @@ class JSCam { ExternalInterface.addCallback("save", null, save); + ExternalInterface.addCallback("pauseCamera", null, pauseCamera); + ExternalInterface.addCallback("resumeCamera", null, resumeCamera); + ExternalInterface.addCallback("setCamera", null, setCamera); ExternalInterface.addCallback("getCameraList", null, getCameraList); @@ -86,6 +89,13 @@ class JSCam { ExternalInterface.call('webcam.debug', "error", "No camera was detected."); } } + public static function pauseCamera():Void { + _root.video.attachVideo(null); + } + public static function resumeCamera():Void { + _root.video.attachVideo(camera); + } + public static function capture(time:Number):Boolean { From 0b21b82454539f0ac1513275eb13a00e48896884 Mon Sep 17 00:00:00 2001 From: Diogo Mafra Date: Fri, 22 Feb 2013 11:07:53 -0300 Subject: [PATCH 02/13] Functions called with setTimeout doesn't receive parameters in Internet Explorer --- jquery.webcam.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jquery.webcam.js b/jquery.webcam.js index ba9a945..7149e2e 100644 --- a/jquery.webcam.js +++ b/jquery.webcam.js @@ -48,8 +48,8 @@ this[webcam.append ? "append" : "html"](source); } - (_register = function(run) { - + var run = 3; + (_register = function() { var cam = document.getElementById('XwebcamXobjectX'); if (cam.capture !== undefined) { @@ -81,9 +81,10 @@ webcam.debug("error", "Flash movie not yet registered!"); } else { /* Flash interface not ready yet */ - window.setTimeout(_register, 1000 * (4 - run), run - 1); + run--; + window.setTimeout(_register, 1000 * (4 - run)); } - })(3); + })(); } })(jQuery); From 239f3050577790d4497b8d286c751a1e523e1c9e Mon Sep 17 00:00:00 2001 From: Ramil Date: Sun, 24 Feb 2013 09:17:13 +0400 Subject: [PATCH 03/13] fix bug in IE8 IE8 failed at this line and show empty page --- jquery.webcam.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.webcam.js b/jquery.webcam.js index ba9a945..3e23296 100644 --- a/jquery.webcam.js +++ b/jquery.webcam.js @@ -52,7 +52,7 @@ var cam = document.getElementById('XwebcamXobjectX'); - if (cam.capture !== undefined) { + if (cam && cam.capture !== undefined) { /* Simple callback methods are not allowed :-/ */ webcam.capture = function(x) { From 10b6482b600533c7953da6a166f6447f1c4223f4 Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Wed, 23 Apr 2014 18:49:41 +0200 Subject: [PATCH 04/13] Made it release ready --- bower.json | 26 ++++++++++++++++++++++++++ jquery.webcam.js | 2 +- webcam.jquery.json | 27 +++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 bower.json create mode 100644 webcam.jquery.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..61683af --- /dev/null +++ b/bower.json @@ -0,0 +1,26 @@ +{ + "name": "webcam", + "main": "jquery.webcam.js", + "version": "1.0.0", + "homepage": "http://www.xarg.org/project/jquery-webcam-plugin/", + "description": "A webcam wrapper plugin for jQuery.", + "keywords": [ + "webcam", + "camera", + "flash" + ], + "authors": [ + "Robert Eisele " + ], + "dependencies": { + "jquery": ">=1.5" + }, + "license": [ + "MIT", + "GPL" + ], + "repository": { + "type": "git", + "url": "git://github.com/infusion/jQuery-webcam.git" + } +} \ No newline at end of file diff --git a/jquery.webcam.js b/jquery.webcam.js index 30ee3dd..ac1d6c1 100644 --- a/jquery.webcam.js +++ b/jquery.webcam.js @@ -1,5 +1,5 @@ /** - * @license jQuery webcam plugin v1.0 09/12/2010 + * @license jQuery webcam plugin v1.0.0 09/12/2010 * http://www.xarg.org/project/jquery-webcam-plugin/ * * Copyright (c) 2010, Robert Eisele (robert@xarg.org) diff --git a/webcam.jquery.json b/webcam.jquery.json new file mode 100644 index 0000000..93fc711 --- /dev/null +++ b/webcam.jquery.json @@ -0,0 +1,27 @@ +{ + "name": "webcam", + "title": "jQuery Webcam Plugin", + "description": "A webcam wrapper plugin for jQuery.", + "version": "1.0.0", + "keywords": [ + "webcam", + "camera", + "flash" + ], + "author": { + "name": "Robert Eisele", + "url": "http://www.xarg.org/" + }, + "licenses": [{ + "type": "MIT", + "url": "http://www.opensource.org/licenses/MIT" + }, { + "type": "GPLv2", + "url": "http://www.opensource.org/licenses/GPL-2.0" + }], + "dependencies": { + "jquery": ">=1.5" + }, + "homepage": "https://github.com/infusion/jQuery-webcam", + "demo": "http://www.xarg.org/project/jquery-webcam-plugin/" +} \ No newline at end of file From 7cb75e1f022492c5e1aa10a574a851e7cf2f3aaa Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Sun, 27 Apr 2014 14:38:54 +0200 Subject: [PATCH 05/13] Added a readme file --- README.md | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..307312c --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +jQuery Webcam Plugin +==================== + +Description +----------- +A small wrapper library to be able to communicate with a Flash webcam via JavaScript. + + +Example +------ + +Please note: The camera doesn't work if you have any dom-errors on your page! + + +```html + + +``` + +```javascript + +jQuery("#webcam").webcam({ + + width: 320, + height: 240, + mode: "callback", + 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(";"); + // 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, ... + }, + + onLoad: function () { + // Page load + var cams = webcam.getCameraList(); + for(var i in cams) { + jQuery("#cams").append("
  • " + cams[i] + "
  • "); + } + } +}); + + +``` + + + +Further examples and documentation +========================== +For further details and code examples take a look at the demonstration and documentation page on: + +http://www.xarg.org/project/jquery-webcam-plugin/ + +License +====== +Dual licensed under the MIT or GPL Version 2 licenses. From 4cad3937fb3930f30bf0f91fd70a3fa5b330b6aa Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Sun, 27 Apr 2014 14:41:03 +0200 Subject: [PATCH 06/13] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 307312c..3eaaad3 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ Example Please note: The camera doesn't work if you have any dom-errors on your page! +The Flash object will be embedded into the following Div: ```html - - +
    ``` ```javascript @@ -63,6 +63,7 @@ jQuery("#webcam").webcam({ ``` +If you want to draw the picture onto a canvas, have a look at the source of the page on my blog, linked below. Further examples and documentation From a2081167eebfd0a4d80ca6563cccf9df5394f9a5 Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Sat, 21 Jun 2014 13:54:13 +0200 Subject: [PATCH 07/13] Made CC compatible --- jquery.webcam.js | 64 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/jquery.webcam.js b/jquery.webcam.js index ac1d6c1..4e4b42c 100644 --- a/jquery.webcam.js +++ b/jquery.webcam.js @@ -10,27 +10,27 @@ var webcam = { - extern: null, // external select token to support jQuery dialogs - append: true, // append object instead of overwriting + "extern": null, // external select token to support jQuery dialogs + "append": true, // append object instead of overwriting - width: 320, - height: 240, + "width": 320, + "height": 240, - mode: "callback", // callback | save | stream + "mode": "callback", // callback | save | stream - swffile: "jscam.swf", - quality: 85, + "swffile": "jscam.swf", + "quality": 85, - debug: function () {}, - onCapture: function () {}, - onTick: function () {}, - onSave: function () {}, - onLoad: function () {} + "debug": function () {}, + "onCapture": function () {}, + "onTick": function () {}, + "onSave": function () {}, + "onLoad": function () {} }; - window.webcam = webcam; + window["webcam"] = webcam; - $.fn.webcam = function(options) { + $["fn"]["webcam"] = function(options) { if (typeof options === "object") { for (var ndx in webcam) { @@ -42,52 +42,52 @@ var source = ''; - if (null !== webcam.extern) { - $(webcam.extern)[webcam.append ? "append" : "html"](source); + if (null !== webcam["extern"]) { + $(webcam["extern"])[webcam["append"] ? "append" : "html"](source); } else { - this[webcam.append ? "append" : "html"](source); + this[webcam["append"] ? "append" : "html"](source); } var run = 3; (_register = function() { var cam = document.getElementById('XwebcamXobjectX'); - if (cam && cam.capture !== undefined) { + if (cam && cam["capture"] !== undefined) { /* Simple callback methods are not allowed :-/ */ - webcam.capture = function(x) { + webcam["capture"] = function(x) { try { - return cam.capture(x); + return cam["capture"](x); } catch(e) {} } - webcam.save = function(x) { + webcam["save"] = function(x) { try { - return cam.save(x); + return cam["save"](x); } catch(e) {} } - webcam.setCamera = function(x) { + webcam["setCamera"] = function(x) { try { - return cam.setCamera(x); + return cam["setCamera"](x); } catch(e) {} } - webcam.getCameraList = function() { + webcam["getCameraList"] = function() { try { - return cam.getCameraList(); + return cam["getCameraList"](); } catch(e) {} } - webcam.pauseCamera = function() { + webcam["pauseCamera"] = function() { try { - return cam.pauseCamera(); + return cam["pauseCamera"](); } catch(e) {} } - webcam.resumeCamera = function() { + webcam["resumeCamera"] = function() { try { - return cam.resumeCamera(); + return cam["resumeCamera"](); } catch(e) {} } - webcam.onLoad(); + webcam["onLoad"](); } else if (0 == run) { - webcam.debug("error", "Flash movie not yet registered!"); + webcam["debug"]("error", "Flash movie not yet registered!"); } else { /* Flash interface not ready yet */ run--; From 04dfe89e0b6f9e7bbe5d924812a0f73bff11901c Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Sat, 21 Jun 2014 13:55:22 +0200 Subject: [PATCH 08/13] Added min file --- jquery.webcam.min.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 jquery.webcam.min.js diff --git a/jquery.webcam.min.js b/jquery.webcam.min.js new file mode 100644 index 0000000..b0a31f5 --- /dev/null +++ b/jquery.webcam.min.js @@ -0,0 +1,10 @@ +/* + jQuery webcam plugin v1.0.0 09/12/2010 + http://www.xarg.org/project/jquery-webcam-plugin/ + + Copyright (c) 2010, Robert Eisele (robert@xarg.org) + Dual licensed under the MIT or GPL Version 2 licenses. +*/ +(function(f){var a={extern:null,append:!0,width:320,height:240,mode:"callback",swffile:"jscam.swf",quality:85,debug:function(){},onCapture:function(){},onTick:function(){},onSave:function(){},onLoad:function(){}};window.webcam=a;f.fn.webcam=function(b){if("object"===typeof b)for(var d in a)void 0!==b[d]&&(a[d]=b[d]);b='';if(null!==a.extern)f(a.extern)[a.append?"append":"html"](b);else this[a.append?"append":"html"](b);var e=3;(_register=function(){var c=document.getElementById("XwebcamXobjectX");c&&void 0!==c.capture?(a.capture=function(a){try{return c.capture(a)}catch(b){}},a.save=function(a){try{return c.save(a)}catch(b){}},a.setCamera=function(a){try{return c.setCamera(a)}catch(b){}},a.getCameraList=function(){try{return c.getCameraList()}catch(a){}}, +a.pauseCamera=function(){try{return c.pauseCamera()}catch(a){}},a.resumeCamera=function(){try{return c.resumeCamera()}catch(a){}},a.onLoad()):0==e?a.debug("error","Flash movie not yet registered!"):(e--,window.setTimeout(_register,1E3*(4-e)))})()}})(jQuery); From 3df10f8a37d5893caf876ae51b11c7d1324549b9 Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Sat, 21 Jun 2014 14:17:42 +0200 Subject: [PATCH 09/13] Update jquery.webcam.js --- jquery.webcam.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.webcam.js b/jquery.webcam.js index 4e4b42c..cd3655e 100644 --- a/jquery.webcam.js +++ b/jquery.webcam.js @@ -40,7 +40,7 @@ } } - var source = ''; + var source = ''; if (null !== webcam["extern"]) { $(webcam["extern"])[webcam["append"] ? "append" : "html"](source); From 50cda04cb790ada00d7744e13b968c963d5435a0 Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Sat, 21 Jun 2014 14:18:01 +0200 Subject: [PATCH 10/13] Update jquery.webcam.min.js --- jquery.webcam.min.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jquery.webcam.min.js b/jquery.webcam.min.js index b0a31f5..97e7c57 100644 --- a/jquery.webcam.min.js +++ b/jquery.webcam.min.js @@ -5,6 +5,6 @@ Copyright (c) 2010, Robert Eisele (robert@xarg.org) Dual licensed under the MIT or GPL Version 2 licenses. */ -(function(f){var a={extern:null,append:!0,width:320,height:240,mode:"callback",swffile:"jscam.swf",quality:85,debug:function(){},onCapture:function(){},onTick:function(){},onSave:function(){},onLoad:function(){}};window.webcam=a;f.fn.webcam=function(b){if("object"===typeof b)for(var d in a)void 0!==b[d]&&(a[d]=b[d]);b='';if(null!==a.extern)f(a.extern)[a.append?"append":"html"](b);else this[a.append?"append":"html"](b);var e=3;(_register=function(){var c=document.getElementById("XwebcamXobjectX");c&&void 0!==c.capture?(a.capture=function(a){try{return c.capture(a)}catch(b){}},a.save=function(a){try{return c.save(a)}catch(b){}},a.setCamera=function(a){try{return c.setCamera(a)}catch(b){}},a.getCameraList=function(){try{return c.getCameraList()}catch(a){}}, +(function(f){var a={extern:null,append:!0,width:320,height:240,mode:"callback",swffile:"jscam.swf",quality:85,debug:function(){},onCapture:function(){},onTick:function(){},onSave:function(){},onLoad:function(){}};window.webcam=a;f.fn.webcam=function(b){if("object"===typeof b)for(var d in a)void 0!==b[d]&&(a[d]=b[d]);b='';if(null!==a.extern)f(a.extern)[a.append?"append":"html"](b);else this[a.append?"append":"html"](b);var e=3;(_register=function(){var c=document.getElementById("XwebcamXobjectX");c&&void 0!==c.capture?(a.capture=function(a){try{return c.capture(a)}catch(b){}},a.save=function(a){try{return c.save(a)}catch(b){}},a.setCamera=function(a){try{return c.setCamera(a)}catch(b){}},a.getCameraList=function(){try{return c.getCameraList()}catch(a){}}, a.pauseCamera=function(){try{return c.pauseCamera()}catch(a){}},a.resumeCamera=function(){try{return c.resumeCamera()}catch(a){}},a.onLoad()):0==e?a.debug("error","Flash movie not yet registered!"):(e--,window.setTimeout(_register,1E3*(4-e)))})()}})(jQuery); From 2d9cffa44c56c812dc5278c54c4d0b653b7c664a Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Mon, 20 Mar 2017 15:58:24 +0100 Subject: [PATCH 11/13] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3eaaad3..ef1b2ad 100644 --- a/README.md +++ b/README.md @@ -74,4 +74,5 @@ http://www.xarg.org/project/jquery-webcam-plugin/ License ====== +Copyright (c) 2013, [Robert Eisele](http://www.xarg.org/) Dual licensed under the MIT or GPL Version 2 licenses. From 76371dff318288e451942b332ca02d841e5215d4 Mon Sep 17 00:00:00 2001 From: LboAnn Date: Mon, 1 May 2017 11:24:46 +0200 Subject: [PATCH 12/13] add CDNJS version badge in README.md This badge will show the version on CDNJS! --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ef1b2ad..71c141f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ jQuery Webcam Plugin ==================== +[![CDNJS version](https://img.shields.io/cdnjs/v/jQuery-webcam.svg)](https://cdnjs.com/libraries/jQuery-webcam) + Description ----------- From 96fff101c8bd0346ce7ea42c67fde2ba9e33278a Mon Sep 17 00:00:00 2001 From: Robert Eisele Date: Thu, 4 Apr 2024 14:36:16 +0200 Subject: [PATCH 13/13] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 71c141f..47b2c20 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,9 @@ Further examples and documentation ========================== For further details and code examples take a look at the demonstration and documentation page on: -http://www.xarg.org/project/jquery-webcam-plugin/ +[https://raw.org/article/camara-support-in-html5-and-javascript/](https://raw.org/article/camara-support-in-html5-and-javascript/) License ====== -Copyright (c) 2013, [Robert Eisele](http://www.xarg.org/) +Copyright (c) 2013, [Robert Eisele](https://raw.org/) Dual licensed under the MIT or GPL Version 2 licenses.