|
@@ -58,6 +58,64 @@ function connect(roomName) {
|
58
|
58
|
});
|
59
|
59
|
}
|
60
|
60
|
|
|
61
|
+/**
|
|
62
|
+ * Creates local media tracks and connects to room. Will show error
|
|
63
|
+ * dialogs in case if accessing local microphone and/or camera failed. Will
|
|
64
|
+ * show guidance overlay for users on how to give access to camera and/or
|
|
65
|
+ * microphone,
|
|
66
|
+ * @param {string} roomName
|
|
67
|
+ * @returns {Promise.<JitsiLocalTrack[], JitsiConnection>}
|
|
68
|
+ */
|
|
69
|
+function createInitialLocalTracksAndConnect(roomName) {
|
|
70
|
+ let audioAndVideoError,
|
|
71
|
+ audioOnlyError,
|
|
72
|
+ tracksCreated;
|
|
73
|
+
|
|
74
|
+ // First try to retrieve both audio and video.
|
|
75
|
+ let tryCreateLocalTracks = createLocalTracks(['audio', 'video'])
|
|
76
|
+ .catch(err => {
|
|
77
|
+ // If failed then try to retrieve only audio.
|
|
78
|
+ audioAndVideoError = err;
|
|
79
|
+ return createLocalTracks(['audio']);
|
|
80
|
+ })
|
|
81
|
+ .catch(err => {
|
|
82
|
+ // If audio failed too then just return empty array for tracks.
|
|
83
|
+ audioOnlyError = err;
|
|
84
|
+ return [];
|
|
85
|
+ })
|
|
86
|
+ .then(tracks => {
|
|
87
|
+ tracksCreated = true;
|
|
88
|
+ return tracks;
|
|
89
|
+ });
|
|
90
|
+
|
|
91
|
+ window.setTimeout(() => {
|
|
92
|
+ if (!audioAndVideoError && !audioOnlyError && !tracksCreated) {
|
|
93
|
+ APP.UI.showUserMediaPermissionsGuidanceOverlay();
|
|
94
|
+ }
|
|
95
|
+ }, USER_MEDIA_PERMISSIONS_GUIDANCE_OVERLAY_TIMEOUT);
|
|
96
|
+
|
|
97
|
+ return Promise.all([ tryCreateLocalTracks, connect(roomName) ])
|
|
98
|
+ .then(([tracks, con]) => {
|
|
99
|
+ APP.UI.hideUserMediaPermissionsGuidanceOverlay();
|
|
100
|
+
|
|
101
|
+ if (audioAndVideoError) {
|
|
102
|
+ if (audioOnlyError) {
|
|
103
|
+ // If both requests for 'audio' + 'video' and 'audio' only
|
|
104
|
+ // failed, we assume that there is some problems with user's
|
|
105
|
+ // microphone and show corresponding dialog.
|
|
106
|
+ APP.UI.showDeviceErrorDialog(audioOnlyError, null);
|
|
107
|
+ } else {
|
|
108
|
+ // If request for 'audio' + 'video' failed, but request for
|
|
109
|
+ // 'audio' only was OK, we assume that we had problems with
|
|
110
|
+ // camera and show corresponding dialog.
|
|
111
|
+ APP.UI.showDeviceErrorDialog(null, audioAndVideoError);
|
|
112
|
+ }
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ return [tracks, con];
|
|
116
|
+ });
|
|
117
|
+}
|
|
118
|
+
|
61
|
119
|
/**
|
62
|
120
|
* Share data to other users.
|
63
|
121
|
* @param command the command
|
|
@@ -403,7 +461,6 @@ export default {
|
403
|
461
|
* @returns {Promise}
|
404
|
462
|
*/
|
405
|
463
|
init(options) {
|
406
|
|
- let self = this;
|
407
|
464
|
this.roomName = options.roomName;
|
408
|
465
|
JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
|
409
|
466
|
|
|
@@ -429,85 +486,38 @@ export default {
|
429
|
486
|
};
|
430
|
487
|
}
|
431
|
488
|
|
432
|
|
- let audioAndVideoError,
|
433
|
|
- audioOnlyError,
|
434
|
|
- tracksCreated;
|
435
|
|
-
|
436
|
|
- return JitsiMeetJS.init(config).then(() => {
|
437
|
|
- let tryCreateLocalTracks =
|
438
|
|
- // try to retrieve audio and video
|
439
|
|
- createLocalTracks(['audio', 'video'])
|
440
|
|
- // if failed then try to retrieve only audio
|
441
|
|
- .catch(err => {
|
442
|
|
- audioAndVideoError = err;
|
443
|
|
- return createLocalTracks(['audio']);
|
444
|
|
- })
|
445
|
|
- // if audio also failed then just return empty array
|
446
|
|
- .catch(err => {
|
447
|
|
- audioOnlyError = err;
|
448
|
|
- return [];
|
449
|
|
- })
|
450
|
|
- .then(tracks => {
|
451
|
|
- tracksCreated = true;
|
452
|
|
- return tracks;
|
453
|
|
- });
|
454
|
|
-
|
455
|
|
- window.setTimeout(() => {
|
456
|
|
- if (!audioAndVideoError && !audioOnlyError && !tracksCreated) {
|
457
|
|
- APP.UI.showUserMediaPermissionsGuidanceOverlay();
|
|
489
|
+ return JitsiMeetJS.init(config)
|
|
490
|
+ .then(() => createInitialLocalTracksAndConnect(options.roomName))
|
|
491
|
+ .then(([tracks, con]) => {
|
|
492
|
+ console.log('initialized with %s local tracks', tracks.length);
|
|
493
|
+ APP.connection = connection = con;
|
|
494
|
+ this._createRoom(tracks);
|
|
495
|
+ this.isDesktopSharingEnabled =
|
|
496
|
+ JitsiMeetJS.isDesktopSharingEnabled();
|
|
497
|
+ if(this.isDesktopSharingEnabled)
|
|
498
|
+ APP.API.addPostisMessageListener('toggle-share-screen',
|
|
499
|
+ () => this.toggleScreenSharing());
|
|
500
|
+
|
|
501
|
+ // if user didn't give access to mic or camera or doesn't have
|
|
502
|
+ // them at all, we disable corresponding toolbar buttons
|
|
503
|
+ if (!tracks.find((t) => t.isAudioTrack())) {
|
|
504
|
+ APP.UI.disableMicrophoneButton();
|
458
|
505
|
}
|
459
|
|
- }, USER_MEDIA_PERMISSIONS_GUIDANCE_OVERLAY_TIMEOUT);
|
460
|
|
-
|
461
|
|
- return Promise.all([
|
462
|
|
- tryCreateLocalTracks,
|
463
|
|
- connect(options.roomName)
|
464
|
|
- ]);
|
465
|
|
- }).then(([tracks, con]) => {
|
466
|
|
- APP.UI.hideUserMediaPermissionsGuidanceOverlay();
|
467
|
506
|
|
468
|
|
- if (audioAndVideoError) {
|
469
|
|
- if (audioOnlyError) {
|
470
|
|
- // If both requests for 'audio' + 'video' and 'audio' only
|
471
|
|
- // failed, we assume that there is some problems with user's
|
472
|
|
- // microphone and show corresponding dialog.
|
473
|
|
- APP.UI.showDeviceErrorDialog(audioOnlyError, null);
|
474
|
|
- } else {
|
475
|
|
- // If request for 'audio' + 'video' failed, but request for
|
476
|
|
- // 'audio' only was OK, we assume that we had problems with
|
477
|
|
- // camera and show corresponding dialog.
|
478
|
|
- APP.UI.showDeviceErrorDialog(null, audioAndVideoError);
|
|
507
|
+ if (!tracks.find((t) => t.isVideoTrack())) {
|
|
508
|
+ APP.UI.disableCameraButton();
|
479
|
509
|
}
|
480
|
|
- }
|
481
|
510
|
|
482
|
|
- console.log('initialized with %s local tracks', tracks.length);
|
483
|
|
- APP.connection = connection = con;
|
484
|
|
- this._createRoom(tracks);
|
485
|
|
- this.isDesktopSharingEnabled =
|
486
|
|
- JitsiMeetJS.isDesktopSharingEnabled();
|
487
|
|
- if(this.isDesktopSharingEnabled)
|
488
|
|
- APP.API.addPostisMessageListener('toggle-share-screen',
|
489
|
|
- () => this.toggleScreenSharing());
|
490
|
|
-
|
491
|
|
- // if user didn't give access to mic or camera or doesn't have
|
492
|
|
- // them at all, we disable corresponding toolbar buttons
|
493
|
|
- if (!tracks.find((t) => t.isAudioTrack())) {
|
494
|
|
- APP.UI.disableMicrophoneButton();
|
495
|
|
- }
|
496
|
|
-
|
497
|
|
- if (!tracks.find((t) => t.isVideoTrack())) {
|
498
|
|
- APP.UI.disableCameraButton();
|
499
|
|
- }
|
|
511
|
+ this._initDeviceList();
|
500
|
512
|
|
501
|
|
- this._initDeviceList();
|
|
513
|
+ if (config.iAmRecorder)
|
|
514
|
+ this.recorder = new Recorder();
|
502
|
515
|
|
503
|
|
- if (config.iAmRecorder)
|
504
|
|
- this.recorder = new Recorder();
|
505
|
|
-
|
506
|
|
- // XXX The API will take care of disconnecting from the XMPP server
|
507
|
|
- // (and, thus, leaving the room) on unload.
|
508
|
|
- return new Promise((resolve, reject) => {
|
509
|
|
- (new ConferenceConnector(resolve, reject)).connect();
|
510
|
|
- });
|
|
516
|
+ // XXX The API will take care of disconnecting from the XMPP
|
|
517
|
+ // server (and, thus, leaving the room) on unload.
|
|
518
|
+ return new Promise((resolve, reject) => {
|
|
519
|
+ (new ConferenceConnector(resolve, reject)).connect();
|
|
520
|
+ });
|
511
|
521
|
});
|
512
|
522
|
},
|
513
|
523
|
/**
|