Handles track removed and removes video elements. When switching on and off desktop sharing video elements number grow under remote video span.

This commit is contained in:
damencho 2016-02-23 16:47:55 -06:00
parent 1a656c2c89
commit 3c61bac3c8
5 changed files with 32 additions and 5 deletions

View File

@ -670,7 +670,10 @@ export default {
});
room.on(ConferenceEvents.TRACK_REMOVED, (track) => {
// FIXME handle
if(!track || track.isLocal())
return;
APP.UI.removeRemoteStream(track);
});
room.on(ConferenceEvents.TRACK_MUTE_CHANGED, (track) => {

View File

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

View File

@ -143,14 +143,16 @@ if (!interfaceConfig.filmStripOnly) {
* @param stream the MediaStream
* @param isVideo <tt>true</tt> if given <tt>stream</tt> is a video one.
*/
RemoteVideo.prototype.removeRemoteStreamElement =
function (stream, isVideo, id) {
RemoteVideo.prototype.removeRemoteStreamElement = function (stream) {
if (!this.container)
return false;
var isVideo = stream.isVideoTrack();
var elementID = SmallVideo.getStreamElementID(stream);
var select = null;
if (isVideo) {
select = $('#' + id);
select = $('#' + elementID);
}
else
select = $('#' + this.videoSpanId + '>audio');

View File

@ -129,7 +129,7 @@ SmallVideo.createStreamElement = function (stream) {
RTCUIHelper.setAutoPlay(element, true);
element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + stream.getId();
element.id = SmallVideo.getStreamElementID(stream);
element.onplay = function () {
console.log("(TIME) Render " + (isVideo ? 'video' : 'audio') + ":\t",
@ -141,6 +141,15 @@ SmallVideo.createStreamElement = function (stream) {
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.
*/

View File

@ -269,6 +269,11 @@ var VideoLayout = {
}
},
onRemoteStreamRemoved (stream) {
let id = stream.getParticipantId();
remoteVideos[id].removeRemoteStreamElement(stream);
},
/**
* Return the type of the remote video.
* @param id the id for the remote video