Procházet zdrojové kódy

fix(remotecontrol): Handle on-stage participant changes

j8
hristoterezov před 8 roky
rodič
revize
5d22061c0a

+ 3
- 0
modules/UI/videolayout/LargeVideoManager.js Zobrazit soubor

@@ -3,6 +3,7 @@ const logger = require("jitsi-meet-logger").getLogger(__filename);
3 3
 
4 4
 import Avatar from "../avatar/Avatar";
5 5
 import {createDeferred} from '../../util/helpers';
6
+import UIEvents from "../../../service/UI/UIEvents";
6 7
 import UIUtil from "../util/UIUtil";
7 8
 import {VideoContainer, VIDEO_CONTAINER_TYPE} from "./VideoContainer";
8 9
 
@@ -19,6 +20,7 @@ export default class LargeVideoManager {
19 20
          * @type {Object.<string, LargeContainer>}
20 21
          */
21 22
         this.containers = {};
23
+        this.eventEmitter = emitter;
22 24
 
23 25
         this.state = VIDEO_CONTAINER_TYPE;
24 26
         this.videoContainer = new VideoContainer(
@@ -164,6 +166,7 @@ export default class LargeVideoManager {
164 166
             // after everything is done check again if there are any pending
165 167
             // new streams.
166 168
             this.updateInProcess = false;
169
+            this.eventEmitter.emit(UIEvents.LARGE_VIDEO_ID_CHANGED, this.id);
167 170
             this.scheduleLargeVideoUpdate();
168 171
         });
169 172
     }

+ 4
- 0
modules/UI/videolayout/RemoteVideo.js Zobrazit soubor

@@ -245,6 +245,10 @@ RemoteVideo.prototype._requestRemoteControlPermissions = function () {
245 245
             {user: this.user.getDisplayName()
246 246
                 || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME}
247 247
         );
248
+        let pinnedId = this.VideoLayout.getPinnedId();
249
+        if(pinnedId !== this.id) {
250
+            this.VideoLayout.handleVideoThumbClicked(this.id);
251
+        }
248 252
     }, error => {
249 253
         logger.error(error);
250 254
         this.updateRemoteVideoMenu(this.isAudioMuted, true);

+ 77
- 13
modules/remotecontrol/Controller.js Zobrazit soubor

@@ -3,6 +3,7 @@ import * as KeyCodes from "../keycode/keycode";
3 3
 import {EVENT_TYPES, REMOTE_CONTROL_EVENT_TYPE, PERMISSIONS_ACTIONS}
4 4
     from "../../service/remotecontrol/Constants";
5 5
 import RemoteControlParticipant from "./RemoteControlParticipant";
6
+import UIEvents from "../../service/UI/UIEvents";
6 7
 
7 8
 const ConferenceEvents = JitsiMeetJS.events.conference;
8 9
 
@@ -53,10 +54,13 @@ export default class Controller extends RemoteControlParticipant {
53 54
      */
54 55
     constructor() {
55 56
         super();
57
+        this.isCollectingEvents = false;
56 58
         this.controlledParticipant = null;
57 59
         this.requestedParticipant = null;
58 60
         this._stopListener = this._handleRemoteControlStoppedEvent.bind(this);
59 61
         this._userLeftListener = this._onUserLeft.bind(this);
62
+        this._largeVideoChangedListener
63
+            = this._onLargeVideoIdChanged.bind(this);
60 64
     }
61 65
 
62 66
     /**
@@ -162,17 +166,36 @@ export default class Controller extends RemoteControlParticipant {
162 166
     }
163 167
 
164 168
     /**
165
-     * Starts processing the mouse and keyboard events.
169
+     * Starts processing the mouse and keyboard events. Sets conference
170
+     * listeners. Disables keyboard events.
166 171
      */
167 172
     _start() {
168
-        if(!this.enabled)
173
+        if(!this.enabled) {
169 174
             return;
170
-        APP.keyboardshortcut.enable(false);
175
+        }
176
+        APP.UI.addListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
177
+            this._largeVideoChangedListener);
171 178
         APP.conference.addConferenceListener(
172 179
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
173 180
             this._stopListener);
174 181
         APP.conference.addConferenceListener(ConferenceEvents.USER_LEFT,
175 182
             this._userLeftListener);
183
+        this.resume();
184
+    }
185
+
186
+    /**
187
+     * Disables the keyboatd shortcuts. Starts collecting remote control
188
+     * events.
189
+     *
190
+     * It can be used to resume an active remote control session wchich was
191
+     * paused with this.pause().
192
+     */
193
+    resume() {
194
+        if(!this.enabled || this.isCollectingEvents) {
195
+            return;
196
+        }
197
+        this.isCollectingEvents = true;
198
+        APP.keyboardshortcut.enable(false);
176 199
         this.area = $("#largeVideoWrapper");
177 200
         this.area.mousemove(event => {
178 201
             const position = this.area.position();
@@ -203,26 +226,22 @@ export default class Controller extends RemoteControlParticipant {
203 226
 
204 227
     /**
205 228
      * Stops processing the mouse and keyboard events. Removes added listeners.
229
+     * Enables the keyboard shortcuts. Displays dialog to notify the user that
230
+     * remote control session has ended.
206 231
      */
207 232
     _stop() {
208 233
         if(!this.controlledParticipant) {
209 234
             return;
210 235
         }
211
-        APP.keyboardshortcut.enable(true);
236
+        APP.UI.removeListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
237
+            this._largeVideoChangedListener);
212 238
         APP.conference.removeConferenceListener(
213 239
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
214 240
             this._stopListener);
215 241
         APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
216 242
             this._userLeftListener);
217 243
         this.controlledParticipant = null;
218
-        this.area.off( "mousemove" );
219
-        this.area.off( "mousedown" );
220
-        this.area.off( "mouseup" );
221
-        this.area.off( "contextmenu" );
222
-        this.area.off( "dblclick" );
223
-        $(window).off( "keydown");
224
-        $(window).off( "keyup");
225
-        this.area[0].onmousewheel = undefined;
244
+        this.pause();
226 245
         APP.UI.messageHandler.openMessageDialog(
227 246
             "dialog.remoteControlTitle",
228 247
             "dialog.remoteControlStopMessage"
@@ -230,7 +249,13 @@ export default class Controller extends RemoteControlParticipant {
230 249
     }
231 250
 
232 251
     /**
233
-     * Calls this._stop() and sends stop message to the controlled participant.
252
+     * Executes this._stop() mehtod:
253
+     * Stops processing the mouse and keyboard events. Removes added listeners.
254
+     * Enables the keyboard shortcuts. Displays dialog to notify the user that
255
+     * remote control session has ended.
256
+     *
257
+     * In addition:
258
+     * Sends stop message to the controlled participant.
234 259
      */
235 260
     stop() {
236 261
         if(!this.controlledParticipant) {
@@ -242,6 +267,30 @@ export default class Controller extends RemoteControlParticipant {
242 267
         this._stop();
243 268
     }
244 269
 
270
+    /**
271
+     * Pauses the collecting of events and enables the keyboard shortcus. But
272
+     * it doesn't removes any other listeners. Basically the remote control
273
+     * session will be still active after this.pause(), but no events from the
274
+     * controller side will be captured and sent.
275
+     *
276
+     * You can resume the collecting of the events with this.resume().
277
+     */
278
+    pause() {
279
+        if(!this.controlledParticipant) {
280
+            return;
281
+        }
282
+        this.isCollectingEvents = false;
283
+        APP.keyboardshortcut.enable(true);
284
+        this.area.off( "mousemove" );
285
+        this.area.off( "mousedown" );
286
+        this.area.off( "mouseup" );
287
+        this.area.off( "contextmenu" );
288
+        this.area.off( "dblclick" );
289
+        $(window).off( "keydown");
290
+        $(window).off( "keyup");
291
+        this.area[0].onmousewheel = undefined;
292
+    }
293
+
245 294
     /**
246 295
      * Handler for mouse click events.
247 296
      * @param {String} type the type of event ("mousedown"/"mouseup")
@@ -292,4 +341,19 @@ export default class Controller extends RemoteControlParticipant {
292 341
             this._stop();
293 342
         }
294 343
     }
344
+
345
+    /**
346
+     * Handles changes of the participant displayed on the large video.
347
+     * @param {string} id - the user id for the participant that is displayed.
348
+     */
349
+    _onLargeVideoIdChanged(id) {
350
+        if (!this.controlledParticipant) {
351
+            return;
352
+        }
353
+        if(this.controlledParticipant == id) {
354
+            this.resume();
355
+        } else {
356
+            this.pause();
357
+        }
358
+    }
295 359
 }

+ 5
- 0
service/UI/UIEvents.js Zobrazit soubor

@@ -120,6 +120,11 @@ export default {
120 120
      */
121 121
     LARGE_VIDEO_AVATAR_VISIBLE: "UI.large_video_avatar_visible",
122 122
 
123
+    /**
124
+     * Notifies that the displayed particpant id on the largeVideo is changed.
125
+     */
126
+    LARGE_VIDEO_ID_CHANGED: "UI.large_video_id_changed",
127
+
123 128
     /**
124 129
      * Toggling room lock
125 130
      */

Načítá se…
Zrušit
Uložit