Quellcode durchsuchen

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

master
Leonard Kim vor 7 Jahren
Ursprung
Commit
60c68b624e
2 geänderte Dateien mit 36 neuen und 14 gelöschten Zeilen
  1. 15
    7
      modules/UI/videolayout/LocalVideo.js
  2. 21
    7
      modules/UI/videolayout/VideoLayout.js

+ 15
- 7
modules/UI/videolayout/LocalVideo.js Datei anzeigen

@@ -21,9 +21,9 @@ import SmallVideo from './SmallVideo';
21 21
 /**
22 22
  *
23 23
  */
24
-function LocalVideo(VideoLayout, emitter) {
24
+function LocalVideo(VideoLayout, emitter, streamEndedCallback) {
25 25
     this.videoSpanId = 'localVideoContainer';
26
-
26
+    this.streamEndedCallback = streamEndedCallback;
27 27
     this.container = this.createContainer();
28 28
     this.$container = $(this.container);
29 29
     $('#filmstripLocalVideoThumbnail').append(this.container);
@@ -137,17 +137,25 @@ LocalVideo.prototype.changeVideo = function(stream) {
137 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 141
         stream.off(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
146 142
     };
147 143
 
148 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 160
  * Shows or hides the local video container.
153 161
  * @param {boolean} true to make the local video container visible, false

+ 21
- 7
modules/UI/videolayout/VideoLayout.js Datei anzeigen

@@ -105,7 +105,10 @@ const VideoLayout = {
105 105
     init(emitter) {
106 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 113
         // sets default video type of local video
111 114
         // FIXME container type is totally different thing from the video type
@@ -175,10 +178,7 @@ const VideoLayout = {
175 178
 
176 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,8 +348,8 @@ const VideoLayout = {
348 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 355
         this.updateMutedForNoTracks(id, stream.getType());
@@ -1147,6 +1147,20 @@ const VideoLayout = {
1147 1147
         Object.values(remoteVideos).forEach(
1148 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
 

Laden…
Abbrechen
Speichern