|
@@ -8,6 +8,8 @@
|
8
|
8
|
|
9
|
9
|
import postisInit from 'postis';
|
10
|
10
|
|
|
11
|
+import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
|
|
12
|
+
|
11
|
13
|
/**
|
12
|
14
|
* List of the available commands.
|
13
|
15
|
* @type {{
|
|
@@ -43,6 +45,25 @@ let postis;
|
43
|
45
|
*/
|
44
|
46
|
let enabled = false;
|
45
|
47
|
|
|
48
|
+/**
|
|
49
|
+ * The state of screen sharing(started/stopped) before the screen sharing is
|
|
50
|
+ * enabled and initialized.
|
|
51
|
+ * NOTE: This flag help us to cache the state and use it if toggle-share-screen
|
|
52
|
+ * was received before the initialization.
|
|
53
|
+ */
|
|
54
|
+let initialScreenSharingState = false;
|
|
55
|
+
|
|
56
|
+/**
|
|
57
|
+ * Executes on toggle-share-screen command.
|
|
58
|
+ */
|
|
59
|
+function toggleScreenSharing() {
|
|
60
|
+ if(!APP.conference.isDesktopSharingEnabled) {
|
|
61
|
+ initialScreenSharingState = !initialScreenSharingState;
|
|
62
|
+ } else {
|
|
63
|
+ APP.conference.toggleScreenSharing();
|
|
64
|
+ }
|
|
65
|
+}
|
|
66
|
+
|
46
|
67
|
function initCommands() {
|
47
|
68
|
commands = {
|
48
|
69
|
"display-name":
|
|
@@ -52,8 +73,7 @@ function initCommands() {
|
52
|
73
|
"toggle-film-strip": APP.UI.toggleFilmstrip,
|
53
|
74
|
"toggle-chat": APP.UI.toggleChat,
|
54
|
75
|
"toggle-contact-list": APP.UI.toggleContactList,
|
55
|
|
- "toggle-share-screen":
|
56
|
|
- APP.conference.toggleScreenSharing.bind(APP.conference),
|
|
76
|
+ "toggle-share-screen": toggleScreenSharing,
|
57
|
77
|
"video-hangup": () => APP.conference.hangup(),
|
58
|
78
|
"email": APP.conference.changeLocalEmail,
|
59
|
79
|
"avatar-url": APP.conference.changeLocalAvatarUrl,
|
|
@@ -97,6 +117,19 @@ function triggerEvent (name, object) {
|
97
|
117
|
}
|
98
|
118
|
}
|
99
|
119
|
|
|
120
|
+/**
|
|
121
|
+ * Listens for screen sharing enabled events and toggles the screen sharing if
|
|
122
|
+ * needed.
|
|
123
|
+ *
|
|
124
|
+ * @param {boolean} enabled - Current screen sharing enabled status.
|
|
125
|
+ * @returns {void}
|
|
126
|
+ */
|
|
127
|
+function onScreenSharingEnable(enabled = false) {
|
|
128
|
+ if(enabled && initialScreenSharingState) {
|
|
129
|
+ toggleScreenSharing();
|
|
130
|
+ }
|
|
131
|
+}
|
|
132
|
+
|
100
|
133
|
class API {
|
101
|
134
|
/**
|
102
|
135
|
* Constructs new instance
|
|
@@ -116,7 +149,12 @@ class API {
|
116
|
149
|
if(!shouldBeEnabled() && !options.forceEnable)
|
117
|
150
|
return;
|
118
|
151
|
|
119
|
|
- enabled = true;
|
|
152
|
+ if(!enabled) {
|
|
153
|
+ APP.conference.addListener(
|
|
154
|
+ JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
|
|
155
|
+ onScreenSharingEnable);
|
|
156
|
+ enabled = true;
|
|
157
|
+ }
|
120
|
158
|
|
121
|
159
|
if(!postis) {
|
122
|
160
|
this._initPostis();
|
|
@@ -233,8 +271,12 @@ class API {
|
233
|
271
|
* Removes the listeners.
|
234
|
272
|
*/
|
235
|
273
|
dispose () {
|
236
|
|
- if(enabled)
|
|
274
|
+ if(enabled) {
|
237
|
275
|
postis.destroy();
|
|
276
|
+ APP.conference.removeListener(
|
|
277
|
+ JitsiMeetConferenceEvents.DESKTOP_SHARING_ENABLED_CHANGED,
|
|
278
|
+ onScreenSharingEnable);
|
|
279
|
+ }
|
238
|
280
|
}
|
239
|
281
|
}
|
240
|
282
|
|