浏览代码

fix(remotecontrol): Handle on-stage participant changes

j8
hristoterezov 8 年前
父节点
当前提交
5d22061c0a

+ 3
- 0
modules/UI/videolayout/LargeVideoManager.js 查看文件

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

+ 4
- 0
modules/UI/videolayout/RemoteVideo.js 查看文件

245
             {user: this.user.getDisplayName()
245
             {user: this.user.getDisplayName()
246
                 || interfaceConfig.DEFAULT_REMOTE_DISPLAY_NAME}
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
     }, error => {
252
     }, error => {
249
         logger.error(error);
253
         logger.error(error);
250
         this.updateRemoteVideoMenu(this.isAudioMuted, true);
254
         this.updateRemoteVideoMenu(this.isAudioMuted, true);

+ 77
- 13
modules/remotecontrol/Controller.js 查看文件

3
 import {EVENT_TYPES, REMOTE_CONTROL_EVENT_TYPE, PERMISSIONS_ACTIONS}
3
 import {EVENT_TYPES, REMOTE_CONTROL_EVENT_TYPE, PERMISSIONS_ACTIONS}
4
     from "../../service/remotecontrol/Constants";
4
     from "../../service/remotecontrol/Constants";
5
 import RemoteControlParticipant from "./RemoteControlParticipant";
5
 import RemoteControlParticipant from "./RemoteControlParticipant";
6
+import UIEvents from "../../service/UI/UIEvents";
6
 
7
 
7
 const ConferenceEvents = JitsiMeetJS.events.conference;
8
 const ConferenceEvents = JitsiMeetJS.events.conference;
8
 
9
 
53
      */
54
      */
54
     constructor() {
55
     constructor() {
55
         super();
56
         super();
57
+        this.isCollectingEvents = false;
56
         this.controlledParticipant = null;
58
         this.controlledParticipant = null;
57
         this.requestedParticipant = null;
59
         this.requestedParticipant = null;
58
         this._stopListener = this._handleRemoteControlStoppedEvent.bind(this);
60
         this._stopListener = this._handleRemoteControlStoppedEvent.bind(this);
59
         this._userLeftListener = this._onUserLeft.bind(this);
61
         this._userLeftListener = this._onUserLeft.bind(this);
62
+        this._largeVideoChangedListener
63
+            = this._onLargeVideoIdChanged.bind(this);
60
     }
64
     }
61
 
65
 
62
     /**
66
     /**
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
     _start() {
172
     _start() {
168
-        if(!this.enabled)
173
+        if(!this.enabled) {
169
             return;
174
             return;
170
-        APP.keyboardshortcut.enable(false);
175
+        }
176
+        APP.UI.addListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
177
+            this._largeVideoChangedListener);
171
         APP.conference.addConferenceListener(
178
         APP.conference.addConferenceListener(
172
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
179
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
173
             this._stopListener);
180
             this._stopListener);
174
         APP.conference.addConferenceListener(ConferenceEvents.USER_LEFT,
181
         APP.conference.addConferenceListener(ConferenceEvents.USER_LEFT,
175
             this._userLeftListener);
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
         this.area = $("#largeVideoWrapper");
199
         this.area = $("#largeVideoWrapper");
177
         this.area.mousemove(event => {
200
         this.area.mousemove(event => {
178
             const position = this.area.position();
201
             const position = this.area.position();
203
 
226
 
204
     /**
227
     /**
205
      * Stops processing the mouse and keyboard events. Removes added listeners.
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
     _stop() {
232
     _stop() {
208
         if(!this.controlledParticipant) {
233
         if(!this.controlledParticipant) {
209
             return;
234
             return;
210
         }
235
         }
211
-        APP.keyboardshortcut.enable(true);
236
+        APP.UI.removeListener(UIEvents.LARGE_VIDEO_ID_CHANGED,
237
+            this._largeVideoChangedListener);
212
         APP.conference.removeConferenceListener(
238
         APP.conference.removeConferenceListener(
213
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
239
             ConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
214
             this._stopListener);
240
             this._stopListener);
215
         APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
241
         APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
216
             this._userLeftListener);
242
             this._userLeftListener);
217
         this.controlledParticipant = null;
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
         APP.UI.messageHandler.openMessageDialog(
245
         APP.UI.messageHandler.openMessageDialog(
227
             "dialog.remoteControlTitle",
246
             "dialog.remoteControlTitle",
228
             "dialog.remoteControlStopMessage"
247
             "dialog.remoteControlStopMessage"
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
     stop() {
260
     stop() {
236
         if(!this.controlledParticipant) {
261
         if(!this.controlledParticipant) {
242
         this._stop();
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
      * Handler for mouse click events.
295
      * Handler for mouse click events.
247
      * @param {String} type the type of event ("mousedown"/"mouseup")
296
      * @param {String} type the type of event ("mousedown"/"mouseup")
292
             this._stop();
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 查看文件

120
      */
120
      */
121
     LARGE_VIDEO_AVATAR_VISIBLE: "UI.large_video_avatar_visible",
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
      * Toggling room lock
129
      * Toggling room lock
125
      */
130
      */

正在加载...
取消
保存