forked from sshilko/jQuery-AS3-Webcam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.webcam.as3.js
63 lines (58 loc) · 2.46 KB
/
jquery.webcam.as3.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
/**
* jQuery AS3 Webcam
*
* Copyright (c) 2012, Sergey Shilko ([email protected])
*
* Date: 08/01/2012
*
* @author Sergey Shilko
* @version 1.0
* @see https://github.com/sshilko/jQuery-AS3-Webcam
**/
try {
$(document).ready( function() {
var webcam = {
previewWidth: 320,
previewHeight: 240,
resolutionWidth: 640,
resolutionHeight: 480,
videoDeblocking: 0,
videoSmoothing: 0,
cameraId: 'AS3webcamObject',
callTarget: 'webcam',
bgcolor: '#000000',
isSwfReady: false,
isCameraEnabled: false,
swffile: "sAS3Cam.swf",
cameraEnabled: function () { },
cameraDisabled: function () { },
noCameraFound: function () { },
isClientReady: function () { return true; },
cameraReady: function () { },
cameraConnected: function () {
this.isSwfReady = true;
var cam = document.getElementById(this.cameraId);
this.save = function() { try { return cam.save(); } catch(e) { this.swfApiFail(e); } }
this.setCamera = function(i) { try { return cam.setCamera(i); } catch(e) { this.swfApiFail(e); } }
this.getCameraList = function() { try { return cam.getCameraList(); } catch(e) { this.swfApiFail(e); } }
this.cameraReady();
},
init: function(container, options) {
if (typeof options === "object") {
for (var ndx in webcam) {
if (options[ndx] !== undefined) {
webcam[ndx] = options[ndx];
}
}
}
var source = '<object id="'+this.cameraId+'" type="application/x-shockwave-flash" data="'+webcam.swffile+'" width="'+webcam.previewWidth+'" height="'+webcam.previewHeight+'"><param name="movie" value="'+webcam.swffile+'" /><param name="FlashVars" value="callTarget='+this.callTarget+'&resolutionWidth='+webcam.resolutionWidth+'&resolutionHeight='+webcam.resolutionWidth+'&smoothing='+webcam.videoSmoothing+'&deblocking='+webcam.videoDeblocking+'" /><param name="allowScriptAccess" value="always" /><param name="bgcolor" value="'+webcam.bgcolor+'" /></object>';
$(container).html(source);
return this;
},
swfApiFail: function (e) { },
debug: function () { }
};
window.webcam = webcam;
$.fn.webcam = function(options) { return webcam.init(this, options); };
});
} catch (e) {}