Merge pull request #515 from damencho/handle-track-removed
Handles track removed and removes video elements. Tested by starting/stopping desktop sharing several times and we only have one video and one audio element after the PR is applied.
This commit is contained in:
commit
194b991fb1
|
@ -670,7 +670,10 @@ export default {
|
||||||
});
|
});
|
||||||
|
|
||||||
room.on(ConferenceEvents.TRACK_REMOVED, (track) => {
|
room.on(ConferenceEvents.TRACK_REMOVED, (track) => {
|
||||||
// FIXME handle
|
if(!track || track.isLocal())
|
||||||
|
return;
|
||||||
|
|
||||||
|
APP.UI.removeRemoteStream(track);
|
||||||
});
|
});
|
||||||
|
|
||||||
room.on(ConferenceEvents.TRACK_MUTE_CHANGED, (track) => {
|
room.on(ConferenceEvents.TRACK_MUTE_CHANGED, (track) => {
|
||||||
|
|
|
@ -444,6 +444,14 @@ UI.addRemoteStream = function (track) {
|
||||||
VideoLayout.onRemoteStreamAdded(track);
|
VideoLayout.onRemoteStreamAdded(track);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removed remote stream from UI.
|
||||||
|
* @param {JitsiTrack} track stream to remove
|
||||||
|
*/
|
||||||
|
UI.removeRemoteStream = function (track) {
|
||||||
|
VideoLayout.onRemoteStreamRemoved(track);
|
||||||
|
};
|
||||||
|
|
||||||
function chatAddError(errorMessage, originalText) {
|
function chatAddError(errorMessage, originalText) {
|
||||||
return Chat.chatAddError(errorMessage, originalText);
|
return Chat.chatAddError(errorMessage, originalText);
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,14 +143,16 @@ if (!interfaceConfig.filmStripOnly) {
|
||||||
* @param stream the MediaStream
|
* @param stream the MediaStream
|
||||||
* @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
|
* @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
|
||||||
*/
|
*/
|
||||||
RemoteVideo.prototype.removeRemoteStreamElement =
|
RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
|
||||||
function (stream, isVideo, id) {
|
|
||||||
if (!this.container)
|
if (!this.container)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
var isVideo = stream.isVideoTrack();
|
||||||
|
|
||||||
|
var elementID = SmallVideo.getStreamElementID(stream);
|
||||||
var select = null;
|
var select = null;
|
||||||
if (isVideo) {
|
if (isVideo) {
|
||||||
select = $('#' + id);
|
select = $('#' + elementID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
select = $('#' + this.videoSpanId + '>audio');
|
select = $('#' + this.videoSpanId + '>audio');
|
||||||
|
|
|
@ -129,7 +129,7 @@ SmallVideo.createStreamElement = function (stream) {
|
||||||
|
|
||||||
RTCUIHelper.setAutoPlay(element, true);
|
RTCUIHelper.setAutoPlay(element, true);
|
||||||
|
|
||||||
element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
|
element.id = SmallVideo.getStreamElementID(stream);
|
||||||
|
|
||||||
element.onplay = function () {
|
element.onplay = function () {
|
||||||
console.log("(TIME) Render " + (isVideo ? 'video' : 'audio') + ":\t",
|
console.log("(TIME) Render " + (isVideo ? 'video' : 'audio') + ":\t",
|
||||||
|
@ -141,6 +141,15 @@ SmallVideo.createStreamElement = function (stream) {
|
||||||
return element;
|
return element;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the element id for a particular MediaStream.
|
||||||
|
*/
|
||||||
|
SmallVideo.getStreamElementID = function (stream) {
|
||||||
|
let isVideo = stream.isVideoTrack();
|
||||||
|
|
||||||
|
return (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures hoverIn/hoverOut handlers.
|
* Configures hoverIn/hoverOut handlers.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -269,6 +269,11 @@ var VideoLayout = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRemoteStreamRemoved (stream) {
|
||||||
|
let id = stream.getParticipantId();
|
||||||
|
remoteVideos[id].removeRemoteStreamElement(stream);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the type of the remote video.
|
* Return the type of the remote video.
|
||||||
* @param id the id for the remote video
|
* @param id the id for the remote video
|
||||||
|
|
Loading…
Reference in New Issue