-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathembed-html.js
309 lines (239 loc) · 9.71 KB
/
embed-html.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
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
PipeSDK.onRecordersInserted = function(){
//getting the reference to our recorder objects
tagRecorder = PipeSDK.getRecorderById('first-recorder');
tagRecorder2 = PipeSDK.getRecorderById('second-recorder');
//getting the reference to the custom buttons
recbtn = document.getElementById("recordbtn");
stopbtn = document.getElementById("stopbtn");
playbtn = document.getElementById("playbtn");
pausebtn = document.getElementById("pausebtn");
savebtn = document.getElementById("savebtn");
removebtn = document.getElementById("removebtn");
//disable the record button untill we get the OK from onReadyToRecord
recbtn.disabled = true;
//disable the play and save buttons untill we have something to play or save
playbtn.disabled = true;
savebtn.disabled = true;
//Calling control API methods when the desktop event function onReadyToRecord() is triggered
tagRecorder.onReadyToRecord = function(id, type){
var args = Array.prototype.slice.call(arguments);
__log("onReadyToRecord("+args.join(', ')+")");
//enabling the record button
recbtn.disabled = false;
//adding onclick events to the buttons
recbtn.onclick = function (){
//calling the control API method
tagRecorder.record();
//enabling the stop button, disabling the record button
recbtn.disabled = true;
stopbtn.disabled = false;
//subsequent recordings should disable the newly enabled ability to play or save until we have a new recording
playbtn.disabled = true;
savebtn.disabled = true;
}
stopbtn.onclick = function (){
//calling the control API method
tagRecorder.stopVideo();
//enabling the stop button, disabling the record button
stopbtn.disabled = true;
}
playbtn.onclick = function (){
//calling the control API method
tagRecorder.playVideo();
//enabling pause, disabling play, stop, record and save buttons
playbtn.disabled = true;
stopbtn.disabled = true;
recbtn.disabled = true;
savebtn.disabled = true;
pausebtn.disabled = false;
}
pausebtn.onclick = function (){
//calling the control API method
tagRecorder.pause();
//enabling record, play and save buttons, disabling pause and stop buttons
pausebtn.disabled = true;
stopbtn.disabled = true;
recbtn.disabled = false;
playbtn.disabled = false;
savebtn.disabled = false;
}
savebtn.onclick = function (){
//calling the control API method
tagRecorder.save();
//disabling the save button
savebtn.disabled = true;
}
}
removebtn.onclick = function (){
//calling the control API method
tagRecorder.remove();
//disabling the remove button
removebtn.disabled = true;
}
//========================== Events API for first Recorder ===============================
//DESKTOP EVENTS API
tagRecorder.userHasCamMic = function(id,camNr, micNr){
var args = Array.prototype.slice.call(arguments);
__log("userHasCamMic("+args.join(', ')+")");
}
tagRecorder.btRecordPressed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("btRecordPressed("+args.join(', ')+")");
}
tagRecorder.btStopRecordingPressed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("btStopRecordingPressed("+args.join(', ')+")");
}
tagRecorder.btPlayPressed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("btPlayPressed("+args.join(', ')+")");
}
tagRecorder.btPausePressed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("btPausePressed("+args.join(', ')+")");
}
tagRecorder.onUploadDone = function(recorderId, streamName, streamDuration, audioCodec, videoCodec, fileType, audioOnly, location){
var args = Array.prototype.slice.call(arguments);
__log("onUploadDone("+args.join(', ')+")");
//enabling record, play and save buttons
recbtn.disabled = false;
playbtn.disabled = false;
savebtn.disabled = false;
}
tagRecorder.onCamAccess = function(id, allowed){
var args = Array.prototype.slice.call(arguments);
__log("onCamAccess("+args.join(', ')+")");
}
tagRecorder.onPlaybackComplete = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onPlaybackComplete("+args.join(', ')+")");
//enabling play button, disabling pause button
playbtn.disabled = false;
pausebtn.disabled = true;
//enabling record and save buttons
savebtn.disabled = false;
recbtn.disabled = false;
}
tagRecorder.onRecordingStarted = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onRecordingStarted("+args.join(', ')+")");
}
tagRecorder.onConnectionClosed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onConnectionClosed("+args.join(', ')+")");
}
tagRecorder.onConnectionStatus = function(id, status){
var args = Array.prototype.slice.call(arguments);
__log("onConnectionStatus("+args.join(', ')+")");
}
tagRecorder.onMicActivityLevel = function(id, level){
var args = Array.prototype.slice.call(arguments);
//__log("onMicActivityLevel("+args.join(', ')+")");
}
tagRecorder.onFPSChange = function(id, fps){
var args = Array.prototype.slice.call(arguments);
//__log("onFPSChange("+args.join(', ')+")");
}
tagRecorder.onSaveOk = function(recorderId, streamName, streamDuration, cameraName, micName, audioCodec, videoCodec, filetype, videoId, audioOnly, location){
var args = Array.prototype.slice.call(arguments);
__log("onSaveOk("+args.join(', ')+")");
}
tagRecorder.onFlashReady = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onFlashReady("+args.join(', ')+")");
}
//DESKTOP UPLOAD EVENTS API
tagRecorder.onDesktopVideoUploadStarted = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onDesktopVideoUploadStarted("+args.join(', ')+")");
}
tagRecorder.onDesktopVideoUploadSuccess = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onDesktopVideoUploadSuccess("+args.join(', ')+")");
}
tagRecorder.onDesktopVideoUploadFailed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onDesktopVideoUploadFailed("+args.join(', ')+")");
}
//MOBILE EVENTS API
tagRecorder.onVideoUploadStarted = function(recorderId, filename, filetype, audioOnly){
var args = Array.prototype.slice.call(arguments);
__log("onVideoUploadStarted("+args.join(', ')+")");
}
tagRecorder.onVideoUploadSuccess = function(recorderId, filename, filetype, videoId, audioOnly, location){
var args = Array.prototype.slice.call(arguments);
__log("onVideoUploadSuccess("+args.join(', ')+")");
}
tagRecorder.onVideoUploadProgress = function(recorderId, percent){
var args = Array.prototype.slice.call(arguments);
__log("onVideoUploadProgress("+args.join(', ')+")");
}
tagRecorder.onVideoUploadFailed = function(id, error){
var args = Array.prototype.slice.call(arguments);
__log("onVideoUploadFailed("+args.join(', ')+")");
}
//========================== Events API for second Recorder (not all events are implemented for the second recorder) ===============================
//DESKTOP EVENTS API
tagRecorder2.userHasCamMic = function(id,camNr, micNr){
var args = Array.prototype.slice.call(arguments);
__log("userHasCamMic("+args.join(', ')+")");
}
tagRecorder2.btRecordPressed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("btRecordPressed("+args.join(', ')+")");
}
tagRecorder2.onUploadDone = function(recorderId, streamName, streamDuration, audioCodec, videoCodec, fileType, audioOnly, location){
var args = Array.prototype.slice.call(arguments);
__log("onUploadDone("+args.join(', ')+")");
}
tagRecorder2.onRecordingStarted = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onRecordingStarted("+args.join(', ')+")");
}
tagRecorder2.onConnectionClosed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onConnectionClosed("+args.join(', ')+")");
}
tagRecorder2.onConnectionStatus = function(id, status){
var args = Array.prototype.slice.call(arguments);
__log("onConnectionStatus("+args.join(', ')+")");
}
tagRecorder2.onSaveOk = function(recorderId, streamName, streamDuration, cameraName, micName, audioCodec, videoCodec, filetype, videoId, audioOnly, location){
var args = Array.prototype.slice.call(arguments);
__log("onSaveOk("+args.join(', ')+")");
}
//DESKTOP UPLOAD EVENTS API for first recorder
tagRecorder2.onDesktopVideoUploadStarted = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onDesktopVideoUploadStarted("+args.join(', ')+")");
}
tagRecorder2.onDesktopVideoUploadSuccess = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onDesktopVideoUploadSuccess("+args.join(', ')+")");
}
tagRecorder2.onDesktopVideoUploadFailed = function(id){
var args = Array.prototype.slice.call(arguments);
__log("onDesktopVideoUploadFailed("+args.join(', ')+")");
}
//MOBILE EVENTS API for first recorder
tagRecorder2.onVideoUploadStarted = function(recorderId, filename, filetype, audioOnly){
var args = Array.prototype.slice.call(arguments);
__log("onVideoUploadStarted("+args.join(', ')+")");
}
tagRecorder2.onVideoUploadSuccess = function(recorderId, filename, filetype, videoId, audioOnly, location){
var args = Array.prototype.slice.call(arguments);
__log("onVideoUploadSuccess("+args.join(', ')+")");
}
tagRecorder2.onVideoUploadProgress = function(recorderId, percent){
var args = Array.prototype.slice.call(arguments);
__log("onVideoUploadProgress("+args.join(', ')+")");
}
tagRecorder2.onVideoUploadFailed = function(id, error){
var args = Array.prototype.slice.call(arguments);
__log("onVideoUploadFailed("+args.join(', ')+")");
}
}
//Logger
function __log(e, data) {
log.innerHTML += "\n" + e + " " + (data || '');
}