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

This commit is contained in:
Leonard Kim 2018-05-21 15:10:43 -07:00 committed by virtuacoplenny
parent 92414a346a
commit 60c68b624e
2 changed files with 36 additions and 14 deletions

View File

@ -21,9 +21,9 @@ import SmallVideo from './SmallVideo';
/** /**
* *
*/ */
function LocalVideo(VideoLayout, emitter) { function LocalVideo(VideoLayout, emitter, streamEndedCallback) {
this.videoSpanId = 'localVideoContainer'; this.videoSpanId = 'localVideoContainer';
this.streamEndedCallback = streamEndedCallback;
this.container = this.createContainer(); this.container = this.createContainer();
this.$container = $(this.container); this.$container = $(this.container);
$('#filmstripLocalVideoThumbnail').append(this.container); $('#filmstripLocalVideoThumbnail').append(this.container);
@ -137,17 +137,25 @@ LocalVideo.prototype.changeVideo = function(stream) {
ReactDOM.unmountComponentAtNode(localVideoContainer); ReactDOM.unmountComponentAtNode(localVideoContainer);
} }
// when removing only the video element and we are on stage this._notifyOfStreamEnded();
// update the stage
if (this.isCurrentlyOnLargeVideo()) {
this.VideoLayout.updateLargeVideo(this.id);
}
stream.off(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler); stream.off(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
}; };
stream.on(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler); stream.on(JitsiTrackEvents.LOCAL_TRACK_STOPPED, endedHandler);
}; };
/**
* Notify any subscribers of the local video stream ending.
*
* @private
* @returns {void}
*/
LocalVideo.prototype._notifyOfStreamEnded = function() {
if (this.streamEndedCallback) {
this.streamEndedCallback(this.id);
}
};
/** /**
* Shows or hides the local video container. * Shows or hides the local video container.
* @param {boolean} true to make the local video container visible, false * @param {boolean} true to make the local video container visible, false

View File

@ -105,7 +105,10 @@ const VideoLayout = {
init(emitter) { init(emitter) {
eventEmitter = emitter; eventEmitter = emitter;
localVideoThumbnail = new LocalVideo(VideoLayout, emitter); localVideoThumbnail = new LocalVideo(
VideoLayout,
emitter,
this._updateLargeVideoIfDisplayed.bind(this));
// sets default video type of local video // sets default video type of local video
// FIXME container type is totally different thing from the video type // FIXME container type is totally different thing from the video type
@ -175,10 +178,7 @@ const VideoLayout = {
localVideoThumbnail.changeVideo(stream); localVideoThumbnail.changeVideo(stream);
/* Update if we're currently being displayed */ this._updateLargeVideoIfDisplayed(localId);
if (this.isCurrentlyOnLarge(localId)) {
this.updateLargeVideo(localId);
}
}, },
/** /**
@ -348,8 +348,8 @@ const VideoLayout = {
remoteVideo.removeRemoteStreamElement(stream); remoteVideo.removeRemoteStreamElement(stream);
} }
if (stream.isVideoTrack() && this.isCurrentlyOnLarge(id)) { if (stream.isVideoTrack()) {
this.updateLargeVideo(id); this._updateLargeVideoIfDisplayed(id);
} }
this.updateMutedForNoTracks(id, stream.getType()); this.updateMutedForNoTracks(id, stream.getType());
@ -1147,6 +1147,20 @@ const VideoLayout = {
Object.values(remoteVideos).forEach( Object.values(remoteVideos).forEach(
remoteVideo => remoteVideo.updateRemoteVideoMenu() remoteVideo => remoteVideo.updateRemoteVideoMenu()
); );
},
/**
* Triggers an update of large video if the passed in participant is
* currently displayed on large video.
*
* @param {string} participantId - The participant ID that should trigger an
* update of large video if displayed.
* @returns {void}
*/
_updateLargeVideoIfDisplayed(participantId) {
if (this.isCurrentlyOnLarge(participantId)) {
this.updateLargeVideo(participantId);
}
} }
}; };