-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathVidyoConnector.html
executable file
·454 lines (427 loc) · 17.8 KB
/
VidyoConnector.html
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<!DOCTYPE html>
<html>
<head>
<title>VidyoConnector</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="jquery-3.1.1.min.js"><\/script>')</script>
<script>if (window.module) module = window.module;</script>
<!-- We've provide some simple styling to get you started. -->
<link href="VidyoConnector.css" rel="stylesheet" type="text/css" >
<!-- Here we load the application which knows how to
invoke the VidyoConnector API. -->
<script src="VidyoConnector.js"></script>
<script type="text/javascript">
var configParams = {};
var platformInfo = {};
var webrtcExtensionPath = "";
var webrtcInitializeAttempts = 0;
function onVidyoClientLoaded(status) {
console.log("Status: " + status.state + "Description: " + status.description);
switch (status.state) {
case "READY": // The library is operating normally
$("#connectionStatus").html("Ready to Connect");
$("#helper").addClass("hidden");
$("#optionsVisibilityButton").removeClass("hidden");
$("#renderer").removeClass("hidden");
$("#toolbarLeft").removeClass("hidden");
$("#toolbarCenter").removeClass("hidden");
$("#toolbarRight").removeClass("hidden");
// If configured to autoJoin, then show video full screen immediately
if (configParams.autoJoin === "1") {
$("#optionsVisibilityButton").addClass("showOptions").removeClass("hideOptions");
$("#renderer").addClass("rendererFullScreen").removeClass("rendererWithOptions");
} else
$("#options").removeClass("hidden");
// If WebRTC is being used, specify the screen share extension path.
if (VCUtils.params.webrtc === "true") {
if (status.hasOwnProperty("downloadPathWebRTCExtensionFirefox"))
webrtcExtensionPath = status.downloadPathWebRTCExtensionFirefox;
else if (status.hasOwnProperty("downloadPathWebRTCExtensionChrome"))
webrtcExtensionPath = status.downloadPathWebRTCExtensionChrome;
}
// Determine which Vidyo stack will be used: Native WebRTC, Transcoding WebRTC or Plugin
var useTranscodingWebRTC, performMonitorShare;
if (status.description.indexOf("Native XMPP + WebRTC") > -1) {
// Native WebRTC
useTranscodingWebRTC = false;
performMonitorShare = false;
} else if (status.description.indexOf("WebRTC successfully loaded") > -1) {
// Transcoding WebRTC
useTranscodingWebRTC = true;
performMonitorShare = false;
++webrtcInitializeAttempts;
} else {
// Plugin
useTranscodingWebRTC = false;
performMonitorShare = true;
}
// After the VidyoClient is successfully initialized a global VC object will become available
// All of the VidyoConnector gui and logic is implemented in VidyoConnector.js
StartVidyoConnector(VC, useTranscodingWebRTC, performMonitorShare, webrtcExtensionPath, configParams);
break;
case "RETRYING": // The library operating is temporarily paused
$("#connectionStatus").html("Temporarily unavailable retrying in " + status.nextTimeout/1000 + " seconds");
break;
case "FAILED": // The library operating has stopped
// If WebRTC initialization failed, try again up to 3 times.
if ((status.description.indexOf("Could not initialize WebRTC transport") > -1) && (webrtcInitializeAttempts < 3)) {
// Attempt to start the VidyoConnector again.
StartVidyoConnector(VC, VCUtils.params.webrtc, webrtcExtensionPath, configParams);
++webrtcInitializeAttempts;
} else {
ShowFailed(status);
}
break;
case "FAILEDVERSION": // The library operating has stopped
UpdateHelperPaths(status);
ShowFailedVersion(status);
$("#connectionStatus").html("Failed: " + status.description);
break;
case "NOTAVAILABLE": // The library is not available
UpdateHelperPaths(status);
$("#connectionStatus").html(status.description);
break;
case "TIMEDOUT": // Transcoding Inactivity Timeout
$("#connectionStatus").html("Failed: " + status.description);
$("#messages #error").html('Page timed out due to inactivity. Please refresh your browser and try again.');
break;
}
return true; // Return true to reload the plugins if not available
}
function UpdateHelperPaths(status) {
$("#helperPlugInDownload").attr("href", status.downloadPathPlugIn);
}
function ShowFailed(status) {
var helperText = '';
// Display the error
helperText += '<h2>An error occurred, please reload</h2>';
helperText += '<p>' + status.description + '</p>';
$("#helperText").html(helperText);
$("#failedText").html(helperText);
$("#failed").removeClass("hidden");
$("#connectionStatus").html("Failed: " + status.description);
$("#optionsVisibilityButton").addClass("hidden");
$("#options").addClass("hidden");
}
function ShowFailedVersion(status) {
var helperText = '';
// Display the error
helperText += '<h4>Please Download a new plugIn and restart the browser</h4>';
helperText += '<p>' + status.description + '</p>';
$("#helperText").html(helperText);
}
function loadVidyoClientLibrary(webrtc, plugin) {
// If webrtc, then set webrtcLogLevel
var webrtcLogLevel = "";
if (webrtc) {
// Set the WebRTC log level to either: 'info' (default), 'error', or 'none'
if (configParams.webrtcLogLevel === 'info' || configParams.webrtcLogLevel === 'error' || configParams.webrtcLogLevel == 'none')
webrtcLogLevel = '&webrtcLogLevel=' + configParams.webrtcLogLevel;
else
webrtcLogLevel = '&webrtcLogLevel=info';
}
//We need to ensure we're loading the VidyoClient library and listening for the callback.
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://static.vidyo.io/latest/javascript/VidyoClient/VidyoClient.js?ft=true&onload=onVidyoClientLoaded&webrtc=' + webrtc + '&plugin=' + plugin + webrtcLogLevel;
document.getElementsByTagName('head')[0].appendChild(script);
}
function joinViaBrowser() {
$("#helperText").html("Loading...");
$("#helperPicker").addClass("hidden");
$("#monitorShareParagraph").addClass("hidden");
loadVidyoClientLibrary(true, false);
}
function joinViaPlugIn() {
$("#helperText").html("Don't have the PlugIn?");
$("#helperPicker").addClass("hidden");
$("#helperPlugIn").removeClass("hidden");
loadVidyoClientLibrary(false, true);
}
function loadPlatformInfo(platformInfo) {
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
// Opera 8.0+
platformInfo.isOpera = userAgent.indexOf("Opera") != -1 || userAgent.indexOf('OPR') != -1 ;
// Firefox
platformInfo.isFirefox = userAgent.indexOf("Firefox") != -1 || userAgent.indexOf('FxiOS') != -1 ;
// Chrome 1+
platformInfo.isChrome = userAgent.indexOf("Chrome") != -1 || userAgent.indexOf('CriOS') != -1 ;
// Safari
platformInfo.isSafari = !platformInfo.isFirefox && !platformInfo.isChrome && userAgent.indexOf("Safari") != -1;
// AppleWebKit
platformInfo.isAppleWebKit = !platformInfo.isSafari && !platformInfo.isFirefox && !platformInfo.isChrome && userAgent.indexOf("AppleWebKit") != -1;
// Internet Explorer 6-11
platformInfo.isIE = (userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true );
// Edge 20+
platformInfo.isEdge = !platformInfo.isIE && !!window.StyleMedia;
// Check if Mac
platformInfo.isMac = navigator.platform.indexOf('Mac') > -1;
// Check if Windows
platformInfo.isWin = navigator.platform.indexOf('Win') > -1;
// Check if Linux
platformInfo.isLinux = navigator.platform.indexOf('Linux') > -1;
// Check if iOS
platformInfo.isiOS = userAgent.indexOf("iPad") != -1 || userAgent.indexOf('iPhone') != -1 ;
// Check if Android
platformInfo.isAndroid = userAgent.indexOf("android") > -1;
// Check if Electron
platformInfo.isElectron = (typeof process === 'object') && process.versions && (process.versions.electron !== undefined);
// Check if WebRTC is available
platformInfo.isWebRTCAvailable = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || (navigator.mediaDevices ? navigator.mediaDevices.getUserMedia : undefined)) ? true : false;
// Check if 64bit
platformInfo.is64bit = navigator.userAgent.indexOf('WOW64') > -1 || navigator.userAgent.indexOf('Win64') > -1 || window.navigator.platform == 'Win64';
}
function loadHelperOptions(platformInfo) {
if (!platformInfo.isMac && !platformInfo.isWin && !platformInfo.isLinux) {
if (platformInfo.isWebRTCAvailable) {
/* Supports WebRTC */
$("#joinViaBrowser").removeClass("hidden");
}
} else {
if (platformInfo.isWebRTCAvailable) {
/* Supports WebRTC */
$("#joinViaBrowser").removeClass("hidden");
}
if (platformInfo.isSafari || (platformInfo.isAppleWebKit && platformInfo.isMac) || (platformInfo.isIE && !platformInfo.isEdge)) {
/* Supports Plugins */
$("#joinViaPlugIn").removeClass("hidden");
}
}
}
// Runs when the page loads
$(function() {
var connectorType = getUrlParameterByName("connectorType");
loadPlatformInfo(platformInfo);
// Extract the desired parameter from the browser's location bar
function getUrlParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
// Fill in the form parameters from the URI
var portal = getUrlParameterByName("portal");
if (portal)
$(".portal").val(portal);
var roomPin = getUrlParameterByName("roomPin");
if (roomPin)
$(".roomPin").val(roomPin);
var displayName = getUrlParameterByName("displayName");
if (displayName)
$(".displayName").val(displayName);
var roomKey = getUrlParameterByName("roomKey");
if (roomKey)
$(".roomKey").val(roomKey);
configParams.autoJoin = getUrlParameterByName("autoJoin");
configParams.enableDebug = getUrlParameterByName("enableDebug");
configParams.microphonePrivacy = getUrlParameterByName("microphonePrivacy");
configParams.cameraPrivacy = getUrlParameterByName("cameraPrivacy");
configParams.webrtcLogLevel = getUrlParameterByName("webrtcLogLevel");
configParams.returnURL = getUrlParameterByName("returnURL");
configParams.isIE = platformInfo.isIE;
var hideConfig = getUrlParameterByName("hideConfig");
// If the parameters are passed in the URI, do not display options dialog
if (portal && roomPin && displayName && roomKey) {
$(".optionsParameters").addClass("hiddenPermanent");
}
if (hideConfig=="1") {
$("#options").addClass("hiddenPermanent");
$("#optionsVisibilityButton").addClass("hiddenPermanent");
$("#renderer").addClass("rendererFullScreenPermanent");
}
if (connectorType == "browser") {
joinViaBrowser();
} else if (connectorType == "plugin") {
joinViaPlugIn();
} else {
loadHelperOptions(platformInfo);
}
});
</script>
</head>
<!-- We execute the VidyoConnectorApp library on page load
to hook up all of the events to elements. -->
<body id="vidyoConnector">
<!-- This button toggles the visibility of the options. -->
<button id="optionsVisibilityButton" title="Toggle Options" class="optionsVisibiliyButtonElements hideOptions hidden"></button>
<div id="options" class="options hidden">
<img class="logo" src="Images/VidyoIcon.png"/>
<form>
<div class="optionsParameters">
<p>
<!-- The portal of our backend service. -->
<label>Portal</label>
<input type="text" id="portal" class="portal" value="vidyocloud.com">
</p>
<p>
<!-- This is the display name that other users will see.
-->
<label for="displayName">Display Name</label>
<input id="displayName" class="displayName" type="text" placeholder="Display Name" value="Guest">
</p>
<p>
<!-- This is the "room" or "space" to which you're connecting
the user. Other users who join this same Room will be able to see and hear each other.
-->
<label for="roomKey">Room Key</label>
<input id="roomKey" class="roomKey" type="text" placeholder="Room Key" value="">
</p>
<p>
<label>Room Pin</label>
<input type="text" id="roomPin" class="roomPin" placeholder="Room Pin" value="">
</p>
</div>
<p>
<!-- On page load, this input is filled with a list of all the available cameras on the user's system. -->
<label for="cameras">Camera</label>
<select id="cameras">
<option value='0'>None</option>
</select>
</p>
<p>
<!-- On page load, this input is filled with a list of all the available microphones on the user's system. -->
<label for="microphones">Microphone</label>
<select id="microphones">
<option value='0'>None</option>
</select>
</p>
<p>
<!-- On page load, this input is filled with a list of all the available microphones on the user's system. -->
<label for="speakers">Speaker</label>
<select id="speakers">
<option value='0'>None</option>
</select>
</p>
<p id="monitorShareParagraph">
<!-- On page load, this input is filled with a list of all the available monitor shares on the user's system. -->
<label for="monitorShares">Monitor Share</label>
<select id="monitorShares">
<option value='0'>None</option>
</select>
</p>
<p>
<!-- On page load, this input is filled with a list of all the available window shares on the user's system. -->
<label for="windowShares">Window Share</label>
<select id="windowShares">
<option value='0'>None</option>
</select>
</p>
</form>
<div id="messages">
<!-- All Vidyo-related messages will be inserted into these spans. -->
<span id="error"></span>
<span id="message"></span>
</div>
</div>
<!-- This is the div into which the Vidyo component will be inserted. -->
<div id="renderer" class="rendererWithOptions pluginOverlay hidden">
</div>
<div id="toolbarLeft" class="toolbar hidden">
<span id="participantStatus"></span>
</div>
<div id="toolbarRight" class="toolbar hidden">
<span id="connectionStatus">Initializing</span>
<span id="clientVersion"></span>
</div>
<div id="toolbarCenter" class="toolbar hidden">
<!-- This button toggles the camera privacy on or off. -->
<button id="cameraButton" title="Camera Privacy" class="toolbarButton cameraOn"></button>
<!-- This button joins and leaves the conference. -->
<button id="joinLeaveButton" title="Join Conference" class="toolbarButton callStart"></button>
<!-- This button mutes and unmutes the users' microphone. -->
<button id="microphoneButton" title="Microphone Privacy" class="toolbarButton microphoneOn"></button>
</div>
<div id="helper">
<table>
<tr>
</tr>
<tr>
<td id="helperText">How would you like to join the call?</td>
</tr>
<tr id="helperPicker">
<td>
<table>
<tr>
<td id="joinViaBrowser" class="hidden">
<div class="helperHeader">
<img src="Images/web.svg" onclick="javascript:joinViaBrowser()"/>
</div>
<ul>
<li class="helperCheck"><img src="Images/checkmark.svg"/>
Join immediately
</li>
<li class="helperCheck"><img src="Images/checkmark.svg"/>
No install
</li>
<li class="helperCheck"><img src="Images/checkmark.svg"/>
Good quality
</li>
</ul>
<div class="helperFooter">
<a href="javascript:joinViaBrowser()">Join via the browser</a>
</div>
</td>
<td id="joinViaPlugIn" class="hidden">
<div class="helperHeader">
<img src="Images/download.svg" onclick="javascript:joinViaPlugIn()"/>
</div>
<ul>
<li class="helperCheck"><img src="Images/checkmark.svg"/>
Join from the browser
</li>
<li class="helperCheck"><img src="Images/checkmark.svg"/>
One-time install
</li>
<li class="helperCheck"><img src="Images/checkmark.svg"/>
Best quality
</li>
</ul>
<div class="helperFooter">
<a href="javascript:joinViaPlugIn()">Join via the plugin</a>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr id="helperPlugIn" class="hidden">
<td>
<div class="helperHeader">
<img src="Images/download.svg" onclick="javascript:joinViaBrowser()"/>
</div>
<ul>
<li class="helperCheck"><img src="Images/checkmark.svg"/>
Download and install it now
</li>
<li class="helperCheck"><img src="Images/checkmark.svg"/>
The plugin will launch automatically once installed
</li>
</ul>
<div class="helperFooter">
<a id="helperPlugInDownload" href="">Download</a>
</div>
</td>
</tr>
<tr>
<td>
<div id="downloadContainerLegal">
By clicking "Join" or "Download", you agree to our <a target="_blank" style="color: #6a6a6a;" href="http://www.vidyo.com/eula/">End-User License Agreement</a> & <a target="_blank" style="color: #6a6a6a;" href="http://www.vidyo.com/privacy-policy/">Privacy Policy</a>.
</div>
</td>
</tr>
</table>
</div>
<div id="failed" class="hidden">
<table>
<tr>
<td><img class="logo" src="Images/VidyoIcon.png"/></td>
</tr>
<tr>
<td id="failedText">Error</td>
</tr>
</table>
</div>
</body>
</html>