Przeglądaj źródła

Handles track removed and removes video elements. When switching on and off desktop sharing video elements number grow under remote video span.

master
damencho 10 lat temu
rodzic
commit
3c61bac3c8

+ 4
- 1
conference.js Wyświetl plik

670
         });
670
         });
671
 
671
 
672
         room.on(ConferenceEvents.TRACK_REMOVED, (track) => {
672
         room.on(ConferenceEvents.TRACK_REMOVED, (track) => {
673
-            // FIXME handle
673
+            if(!track || track.isLocal())
674
+                return;
675
+
676
+            APP.UI.removeRemoteStream(track);
674
         });
677
         });
675
 
678
 
676
         room.on(ConferenceEvents.TRACK_MUTE_CHANGED, (track) => {
679
         room.on(ConferenceEvents.TRACK_MUTE_CHANGED, (track) => {

+ 8
- 0
modules/UI/UI.js Wyświetl plik

444
     VideoLayout.onRemoteStreamAdded(track);
444
     VideoLayout.onRemoteStreamAdded(track);
445
 };
445
 };
446
 
446
 
447
+/**
448
+ * Removed remote stream from UI.
449
+ * @param {JitsiTrack} track stream to remove
450
+ */
451
+UI.removeRemoteStream = function (track) {
452
+    VideoLayout.onRemoteStreamRemoved(track);
453
+};
454
+
447
 function chatAddError(errorMessage, originalText) {
455
 function chatAddError(errorMessage, originalText) {
448
     return Chat.chatAddError(errorMessage, originalText);
456
     return Chat.chatAddError(errorMessage, originalText);
449
 }
457
 }

+ 5
- 3
modules/UI/videolayout/RemoteVideo.js Wyświetl plik

143
  * @param stream the MediaStream
143
  * @param stream the MediaStream
144
  * @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
144
  * @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
145
  */
145
  */
146
-RemoteVideo.prototype.removeRemoteStreamElement =
147
-    function (stream, isVideo, id) {
146
+RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
148
     if (!this.container)
147
     if (!this.container)
149
         return false;
148
         return false;
150
 
149
 
150
+    var isVideo = stream.isVideoTrack();
151
+
152
+    var elementID = SmallVideo.getStreamElementID(stream);
151
     var select = null;
153
     var select = null;
152
     if (isVideo) {
154
     if (isVideo) {
153
-        select = $('#' + id);
155
+        select = $('#' + elementID);
154
     }
156
     }
155
     else
157
     else
156
         select = $('#' + this.videoSpanId + '>audio');
158
         select = $('#' + this.videoSpanId + '>audio');

+ 10
- 1
modules/UI/videolayout/SmallVideo.js Wyświetl plik

129
 
129
 
130
     RTCUIHelper.setAutoPlay(element, true);
130
     RTCUIHelper.setAutoPlay(element, true);
131
 
131
 
132
-    element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
132
+    element.id = SmallVideo.getStreamElementID(stream);
133
 
133
 
134
     element.onplay = function () {
134
     element.onplay = function () {
135
         console.log("(TIME) Render " + (isVideo ? 'video' : 'audio') + ":\t",
135
         console.log("(TIME) Render " + (isVideo ? 'video' : 'audio') + ":\t",
141
     return element;
141
     return element;
142
 };
142
 };
143
 
143
 
144
+/**
145
+ * Returns the element id for a particular MediaStream.
146
+ */
147
+SmallVideo.getStreamElementID = function (stream) {
148
+    let isVideo = stream.isVideoTrack();
149
+
150
+    return (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
151
+};
152
+
144
 /**
153
 /**
145
  * Configures hoverIn/hoverOut handlers.
154
  * Configures hoverIn/hoverOut handlers.
146
  */
155
  */

+ 5
- 0
modules/UI/videolayout/VideoLayout.js Wyświetl plik

269
         }
269
         }
270
     },
270
     },
271
 
271
 
272
+    onRemoteStreamRemoved (stream) {
273
+        let id = stream.getParticipantId();
274
+        remoteVideos[id].removeRemoteStreamElement(stream);
275
+    },
276
+
272
     /**
277
     /**
273
      * Return the type of the remote video.
278
      * Return the type of the remote video.
274
      * @param id the id for the remote video
279
      * @param id the id for the remote video

Ładowanie…
Anuluj
Zapisz