瀏覽代碼

ref(video-layout): local video does not call video layout directly on stream end

master
Leonard Kim 7 年之前
父節點
當前提交
60c68b624e
共有 2 個檔案被更改,包括 36 行新增14 行删除
  1. 15
    7
      modules/UI/videolayout/LocalVideo.js
  2. 21
    7
      modules/UI/videolayout/VideoLayout.js

+ 15
- 7
modules/UI/videolayout/LocalVideo.js 查看文件

21
 /**
21
 /**
22
  *
22
  *
23
  */
23
  */
24
-function LocalVideo(VideoLayout, emitter) {
24
+function LocalVideo(VideoLayout, emitter, streamEndedCallback) {
25
     this.videoSpanId = 'localVideoContainer';
25
     this.videoSpanId = 'localVideoContainer';
26
-
26
+    this.streamEndedCallback = streamEndedCallback;
27
     this.container = this.createContainer();
27
     this.container = this.createContainer();
28
     this.$container = $(this.container);
28
     this.$container = $(this.container);
29
     $('#filmstripLocalVideoThumbnail').append(this.container);
29
     $('#filmstripLocalVideoThumbnail').append(this.container);
137
             ReactDOM.unmountComponentAtNode(localVideoContainer);
137
             ReactDOM.unmountComponentAtNode(localVideoContainer);
138
         }
138
         }
139
 
139
 
140
-        // when removing only the video element and we are on stage
141
-        // update the stage
142
-        if (this.isCurrentlyOnLargeVideo()) {
143
-            this.VideoLayout.updateLargeVideo(this.id);
144
-        }
140
+        this._notifyOfStreamEnded();
145
         stream.off(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
141
         stream.off(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
146
     };
142
     };
147
 
143
 
148
     stream.on(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
144
     stream.on(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
149
 };
145
 };
150
 
146
 
147
+/**
148
+ * Notify any subscribers of the local video stream ending.
149
+ *
150
+ * @private
151
+ * @returns {void}
152
+ */
153
+LocalVideo.prototype._notifyOfStreamEnded = function() {
154
+    if (this.streamEndedCallback) {
155
+        this.streamEndedCallback(this.id);
156
+    }
157
+};
158
+
151
 /**
159
 /**
152
  * Shows or hides the local video container.
160
  * Shows or hides the local video container.
153
  * @param {boolean} true to make the local video container visible, false
161
  * @param {boolean} true to make the local video container visible, false

+ 21
- 7
modules/UI/videolayout/VideoLayout.js 查看文件

105
     init(emitter) {
105
     init(emitter) {
106
         eventEmitter = emitter;
106
         eventEmitter = emitter;
107
 
107
 
108
-        localVideoThumbnail = new LocalVideo(VideoLayout, emitter);
108
+        localVideoThumbnail = new LocalVideo(
109
+            VideoLayout,
110
+            emitter,
111
+            this._updateLargeVideoIfDisplayed.bind(this));
109
 
112
 
110
         // sets default video type of local video
113
         // sets default video type of local video
111
         // FIXME container type is totally different thing from the video type
114
         // FIXME container type is totally different thing from the video type
175
 
178
 
176
         localVideoThumbnail.changeVideo(stream);
179
         localVideoThumbnail.changeVideo(stream);
177
 
180
 
178
-        /* Update if we're currently being displayed */
179
-        if (this.isCurrentlyOnLarge(localId)) {
180
-            this.updateLargeVideo(localId);
181
-        }
181
+        this._updateLargeVideoIfDisplayed(localId);
182
     },
182
     },
183
 
183
 
184
     /**
184
     /**
348
             remoteVideo.removeRemoteStreamElement(stream);
348
             remoteVideo.removeRemoteStreamElement(stream);
349
         }
349
         }
350
 
350
 
351
-        if (stream.isVideoTrack() && this.isCurrentlyOnLarge(id)) {
352
-            this.updateLargeVideo(id);
351
+        if (stream.isVideoTrack()) {
352
+            this._updateLargeVideoIfDisplayed(id);
353
         }
353
         }
354
 
354
 
355
         this.updateMutedForNoTracks(id, stream.getType());
355
         this.updateMutedForNoTracks(id, stream.getType());
1147
         Object.values(remoteVideos).forEach(
1147
         Object.values(remoteVideos).forEach(
1148
             remoteVideo => remoteVideo.updateRemoteVideoMenu()
1148
             remoteVideo => remoteVideo.updateRemoteVideoMenu()
1149
         );
1149
         );
1150
+    },
1151
+
1152
+    /**
1153
+     * Triggers an update of large video if the passed in participant is
1154
+     * currently displayed on large video.
1155
+     *
1156
+     * @param {string} participantId - The participant ID that should trigger an
1157
+     * update of large video if displayed.
1158
+     * @returns {void}
1159
+     */
1160
+    _updateLargeVideoIfDisplayed(participantId) {
1161
+        if (this.isCurrentlyOnLarge(participantId)) {
1162
+            this.updateLargeVideo(participantId);
1163
+        }
1150
     }
1164
     }
1151
 };
1165
 };
1152
 
1166
 

Loading…
取消
儲存