-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathscriptcam.js
More file actions
257 lines (222 loc) · 8.44 KB
/
scriptcam.js
File metadata and controls
257 lines (222 loc) · 8.44 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// _____ _ _ _____
// / ___| (_) | | / __ \
// \ `--. ___ _ __ _ _ __ | |_| / \/
// `--. \/ __| '__| | '_ \| __| | / _` | '_ ` _ \
// /\__/ / (__| | | | |_) | |_| \__/\ (_| | | | | | |
// \____/ \___|_| |_| .__/ \__|\____/\__,_|_| |_| |_|
// | |
// Version 1.6.0 |_| (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
data.path=decodeURIComponent(data.path); // convert URI back to normal string
$('#'+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_fileReady=data.fileReady;
$.scriptcam.SC_fileConversionStarted=data.fileConversionStarted;
$.scriptcam.SC_onMotion=data.onMotion;
$.scriptcam.SC_onError=data.onError;
$.scriptcam.SC_onHandLeft=data.onHandLeft;
$.scriptcam.SC_onHandRight=data.onHandRight;
$.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_userLeft=data.userLeft;
$.scriptcam.SC_userJoined=data.userJoined;
$.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);
}
if (opts.canvasHeight && opts.canvasHeight) {
var newWidth=opts.canvasWidth;
var newHeight=opts.canvasHeight;
}
else {
// no canvas dimensions given, make our own horizontal layout
var newWidth=opts.width*opts.zoom;
var newHeight=opts.height*opts.zoom;
if (opts.chatRoom) {
newWidth=(opts.width*opts.zoom)+(opts.width*opts.zoomChat)+5; // make room for two horizontal video windows with a margin of 5
opts.posX=(opts.width*opts.zoom)+5;
newHeight=opts.height*Math.max(opts.zoom,opts.zoomChat);
};
}
// make new dimensions are not below minimum flash size
if (newWidth < 215) {
newWidth=215;
}
if (newHeight < 138) {
newHeight=138;
}
if (opts.rotate!=0 || opts.skewX!=0 || opts.skewY!=0 || opts.flip!=0 || opts.zoom!=1 || opts.zoomChat!=1) {
// no GPU acceleration
var params = {
menu: 'false',
wmode: 'window',
allowScriptAccess: 'always',
allowFullScreen: 'true'
};
}
else {
// GPU acceleration when no filter is used
var params = {
menu: 'false',
wmode: 'direct',
allowScriptAccess: 'always',
allowFullScreen: 'true'
};
};
// Escape all values contained in the flashVars (IE needs this)
for (var key in opts) {
opts[key] = encodeURIComponent(opts[key]);
};
if (fileExists(decodeURIComponent(data.path)+'scriptcam.swf')) {
swfobject.embedSWF(decodeURIComponent(data.path)+'scriptcam.swf', opts.id, newWidth, newHeight, '11.6', false, opts, params);
}
else {
alert(decodeURIComponent(data.path)+'scriptcam.swf not found, please check the path parameter');
}
});
};
function fileExists(url) {
var http = new XMLHttpRequest();
http.open('HEAD', url, false);
http.send();
return http.status==200;
}
$.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.hardwareacceleration=function() {
return $('#'+data.id).get(0).SC_hardwareacceleration();
}
$.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.pauseRecording=function() {
$('#'+data.id).get(0).SC_pauseRecording();
}
$.scriptcam.resumeRecording=function() {
$('#'+data.id).get(0).SC_resumeRecording();
}
$.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.playMP3=function(value) {
$('#'+data.id).get(0).SC_playMP3(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:'',
zoom:1,
zoomChat:1,
rotate:0,
skewX:0,
skewY:0,
flip:0,
noFlashFound:'<p>You need <a href="http://www.adobe.com/go/getflashplayer">Adobe Flash Player 11.7</a> to use this software.<br/>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_fileReady(fileName) {
$.scriptcam.SC_fileReady(fileName);
}
function SC_fileConversionStarted(fileName) {
$.scriptcam.SC_fileConversionStarted(fileName);
}
function SC_onMotion(decodedString) {
$.scriptcam.SC_onMotion(decodedString);
}
function SC_promptWillShow() {
$.scriptcam.SC_promptWillShow();
}
function SC_onHandLeft() {
$.scriptcam.SC_onHandLeft();
}
function SC_onHandRight() {
$.scriptcam.SC_onHandRight();
}
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,motionx,motiony) {
$.scriptcam.SC_onMotion(motion,brightness,color,motionx,motiony);
}
function SC_timeLeft(value) {
$.scriptcam.SC_timeLeft(value);
}
function SC_addChatText(value) {
$.scriptcam.SC_addChatText(value);
}
function SC_userJoined(value) {
$.scriptcam.SC_userJoined(value);
}
function SC_userLeft(value) {
$.scriptcam.SC_userLeft(value);
}