-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscriptcam.js
executable file
·174 lines (147 loc) · 6.43 KB
/
scriptcam.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// _____ _ _ _____
// / ___| (_) | | / __ \
// \ `--. ___ _ __ _ _ __ | |_| / \/ __ _ _ __ ___
// `--. \/ __| '__| | '_ \| __| | / _` | '_ ` _ \
// /\__/ / (__| | | | |_) | |_| \__/\ (_| | | | | | |
// \____/ \___|_| |_| .__/ \__|\____/\__,_|_| |_| |_|
// | |
// Version 1.1.7 |_| (c) Tele-Line Videotex Services
// Use jscompress.com to compress this file
;(function($) {
$.fn.scriptcam=function(options) {
// merge passed options with default values
var opts=$.extend({}, $.fn.scriptcam.defaults, options);
// off we go
return this.each(function() {
// add flash to div
opts.id=this.id; // add id of plugin to the options structure
data=opts; // pass options to jquery internal data field to make them available to the outside world
$('#'+opts.id).html(opts.noFlashFound); // inject no flash found message
// forward incoming flash movie calls to outgoing functions
$.scriptcam.SC_promptWillShow=data.promptWillShow;
$.scriptcam.SC_onMotion=data.onMotion;
$.scriptcam.SC_onError=data.onError;
$.scriptcam.SC_onWebcamReady=data.onWebcamReady;
$.scriptcam.SC_connected=data.connected;
$.scriptcam.SC_onPictureAsBase64=data.onPictureAsBase64;
$.scriptcam.SC_disconnected=data.disconnected;
$.scriptcam.SC_setVolume=data.setVolume;
$.scriptcam.SC_timeLeft=data.timeLeft;
$.scriptcam.SC_addChatText=function(value) {
value = value.replace(":{", '<img src="'+data.path+'angry.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":-{", '<img src="'+data.path+'angry.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":)", '<img src="'+data.path+'smile.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":-)", '<img src="'+data.path+'smile.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":D", '<img src="'+data.path+'biggrin.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":-D", '<img src="'+data.path+'biggrin.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":O", '<img src="'+data.path+'ohmy.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":-O", '<img src="'+data.path+'ohmy.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":(", '<img src="'+data.path+'sad.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":-(", '<img src="'+data.path+'sad.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":p", '<img src="'+data.path+'tongue.gif" width="16" height="16" class="smiley"/>');
value = value.replace(":-p", '<img src="'+data.path+'tongue.gif" width="16" height="16" class="smiley"/>');
value = value.replace(";)", '<img src="'+data.path+'wink.gif" width="16" height="16" class="smiley"/>');
value = value.replace(";-)", '<img src="'+data.path+'wink.gif" width="16" height="16" class="smiley"/>');
$('#'+data.chatWindow).append(value+'<br/>');
$('#'+data.chatWindow).animate({ scrollTop: $('#'+data.chatWindow).prop("scrollHeight") - $('#'+data.chatWindow).height() }, 100);
}
var newWidth=opts.width;
if (opts.chatRoom) {
newWidth=(newWidth*2)+5; // make room for two video windows with a margin of 5 when chatting
}
if (opts.chatRoom || opts.fileName || opts.daeFilename) {
// use GPU acceleration when recording, chatting or AR
var params = {
menu: 'false',
wmode: 'direct'
};
}
else {
// enable HTML overlay when in snapshot mode
var params = {
menu: 'false',
wmode: 'transparent'
};
}
// Escape all values contained in the flashVars (IE needs this)
for (var key in opts) {
opts[key] = encodeURIComponent(opts[key]);
};
swfobject.embedSWF(data.path+'scriptcam.swf', opts.id, newWidth, opts.height, '11.4', false, opts, params);
});
};
$.scriptcam={};
// outgoing functions (calling the flash movie)
$.scriptcam.getFrameAsBase64=function() {
return $('#'+data.id).get(0).SC_getFrameAsBase64();
}
$.scriptcam.version=function() {
return $('#'+data.id).get(0).SC_version();
}
$.scriptcam.getMotionParameters=function() {
$('#'+data.id).get(0).SC_getMotionParameters();
}
$.scriptcam.getBarCode=function() {
return $('#'+data.id).get(0).SC_getBarCode();
}
$.scriptcam.startRecording=function() {
$('#'+data.id).get(0).SC_startRecording();
}
$.scriptcam.closeCamera=function() {
$('#'+data.id).get(0).SC_closeCamera();
}
$.scriptcam.changeVolume=function(value) {
$('#'+data.id).get(0).SC_changeVolume(value);
}
$.scriptcam.sendMessage=function(value) {
$('#'+data.id).get(0).SC_sendMessage(value);
}
$.scriptcam.changeCamera=function(value) {
$('#'+data.id).get(0).SC_changeCamera(value);
}
$.scriptcam.changeMicrophone=function(value) {
$('#'+data.id).get(0).SC_changeMicrophone(value);
}
// set javascript default values (flash default values are managed in the swf file)
$.fn.scriptcam.defaults={
width:320,
height:240,
chatWindow:'chatWindow',
path:'',
noFlashFound:'<p>You need <a href="http://www.adobe.com/go/getflashplayer">Adobe Flash Player 11.4</a> to use this software. Please click on the link to download the installer.</p>'
};
})(jQuery);
// incoming functions (calls coming from flash) - must be public and forward calls to the scriptcam plugin
function SC_onError(errorId,errorMsg) {
$.scriptcam.SC_onError(errorId,errorMsg);
}
function SC_onMotion(decodedString) {
$.scriptcam.SC_onMotion(decodedString);
}
function SC_promptWillShow() {
$.scriptcam.SC_promptWillShow();
}
function SC_onWebcamReady(cameraNames,camera,microphoneNames,microphone) {
$.scriptcam.SC_onWebcamReady(cameraNames,camera,microphoneNames,microphone);
}
function SC_onPictureAsBase64(value) {
$.scriptcam.SC_onPictureAsBase64(value);
}
function SC_connected() {
$.scriptcam.SC_connected();
}
function SC_disconnected() {
$.scriptcam.SC_disconnected();
}
function SC_setVolume(value) {
$.scriptcam.SC_setVolume(value);
}
function SC_onMotion(motion,brightness,color,facearea) {
$.scriptcam.SC_onMotion(motion,brightness,color,facearea);
}
function SC_timeLeft(value) {
$.scriptcam.SC_timeLeft(value);
}
function SC_addChatText(value) {
$.scriptcam.SC_addChatText(value);
}