浏览代码

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 年前
父节点
当前提交
3c61bac3c8

+ 4
- 1
conference.js 查看文件

@@ -670,7 +670,10 @@ export default {
670 670
         });
671 671
 
672 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 679
         room.on(ConferenceEvents.TRACK_MUTE_CHANGED, (track) => {

+ 8
- 0
modules/UI/UI.js 查看文件

@@ -444,6 +444,14 @@ UI.addRemoteStream = function (track) {
444 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 455
 function chatAddError(errorMessage, originalText) {
448 456
     return Chat.chatAddError(errorMessage, originalText);
449 457
 }

+ 5
- 3
modules/UI/videolayout/RemoteVideo.js 查看文件

@@ -143,14 +143,16 @@ if (!interfaceConfig.filmStripOnly) {
143 143
  * @param stream the MediaStream
144 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 147
     if (!this.container)
149 148
         return false;
150 149
 
150
+    var isVideo = stream.isVideoTrack();
151
+
152
+    var elementID = SmallVideo.getStreamElementID(stream);
151 153
     var select = null;
152 154
     if (isVideo) {
153
-        select = $('#' + id);
155
+        select = $('#' + elementID);
154 156
     }
155 157
     else
156 158
         select = $('#' + this.videoSpanId + '>audio');

+ 10
- 1
modules/UI/videolayout/SmallVideo.js 查看文件

@@ -129,7 +129,7 @@ SmallVideo.createStreamElement = function (stream) {
129 129
 
130 130
     RTCUIHelper.setAutoPlay(element, true);
131 131
 
132
-    element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
132
+    element.id = SmallVideo.getStreamElementID(stream);
133 133
 
134 134
     element.onplay = function () {
135 135
         console.log("(TIME) Render " + (isVideo ? 'video' : 'audio') + ":\t",
@@ -141,6 +141,15 @@ SmallVideo.createStreamElement = function (stream) {
141 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 154
  * Configures hoverIn/hoverOut handlers.
146 155
  */

+ 5
- 0
modules/UI/videolayout/VideoLayout.js 查看文件

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

正在加载...
取消
保存