remove user from VideoLayout

This commit is contained in:
isymchych 2015-12-14 16:51:02 +02:00
parent 6ded050b51
commit 36874c395a
1 changed files with 55 additions and 55 deletions

View File

@ -74,6 +74,25 @@ $(ContactList).bind('contactclicked', function(event, id) {
} }
}); });
/**
* Returns the corresponding resource id to the given peer container
* DOM element.
*
* @return the corresponding resource id to the given peer container
* DOM element
*/
function getPeerContainerResourceId (containerElement) {
if (localVideoThumbnail.container === containerElement) {
return localVideoThumbnail.id;
}
let i = containerElement.id.indexOf('participant_');
if (i >= 0) {
return containerElement.id.substring(i + 12);
}
}
var VideoLayout = { var VideoLayout = {
init (emitter) { init (emitter) {
@ -168,58 +187,57 @@ var VideoLayout = {
* another one instead. * another one instead.
*/ */
updateRemovedVideo (id) { updateRemovedVideo (id) {
if (id !== LargeVideo.getId()) {
return;
}
let newId; let newId;
if (id === LargeVideo.getId()) { // We'll show user's avatar if he is the dominant speaker or if
// We'll show user's avatar if he is the dominant speaker or if // his video thumbnail is pinned
// his video thumbnail is pinned if (remoteVideos[id] && (id === focusedVideoResourceJid || id === currentDominantSpeaker)) {
if (remoteVideos[id] && newId = id;
id === focusedVideoResourceJid || } else {
id === currentDominantSpeaker) { // Otherwise select last visible video
newId = id; newId = this.electLastVisibleVideo();
} else {
// Otherwise select last visible video
newId = this.electLastVisibleVideo();
}
LargeVideo.updateLargeVideo(id);
} }
LargeVideo.updateLargeVideo(newId);
}, },
electLastVisibleVideo () { electLastVisibleVideo () {
// pick the last visible video in the row // pick the last visible video in the row
// if nobody else is left, this picks the local video // if nobody else is left, this picks the local video
var jid; let pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last');
var pick = $('#remoteVideos>span[id!="mixedstream"]:visible:last');
if (pick.length) { if (pick.length) {
jid = VideoLayout.getPeerContainerResourceJid(pick[0]); let id = getPeerContainerResourceId(pick[0]);
if (!remoteVideos[jid]) { if (remoteVideos[id]) {
// The RemoteVideo was removed (but the DOM elements may still console.info("electLastVisibleVideo: " + id);
// exist). return id;
jid = null;
} }
// The RemoteVideo was removed (but the DOM elements may still
// exist).
} }
if (!jid) { console.info("Last visible video no longer exists");
console.info("Last visible video no longer exists"); pick = $('#remoteVideos>span[id!="mixedstream"]');
pick = $('#remoteVideos>span[id!="mixedstream"]'); if (pick.length) {
if (pick.length) { let id = getPeerContainerResourceId(pick[0]);
jid = VideoLayout.getPeerContainerResourceJid(pick[0]); if (remoteVideos[id]) {
if (!remoteVideos[jid]) { console.info("electLastVisibleVideo: " + id);
// The RemoteVideo was removed (but the DOM elements may return id;
// still exist).
jid = null;
}
} }
// The RemoteVideo was removed (but the DOM elements may
// still exist).
} }
if (!jid) { // Go with local video
// Go with local video console.info("Fallback to local video...");
console.info("Fallback to local video...");
jid = APP.xmpp.myResource();
}
console.info("electLastVisibleVideo: " + jid); let id = APP.conference.localId;
return jid; console.info("electLastVisibleVideo: " + id);
return id;
}, },
onRemoteStreamAdded (stream) { onRemoteStreamAdded (stream) {
@ -508,24 +526,6 @@ var VideoLayout = {
return [availableWidth, availableHeight]; return [availableWidth, availableHeight];
}, },
/**
* Returns the corresponding resource jid to the given peer container
* DOM element.
*
* @return the corresponding resource jid to the given peer container
* DOM element
*/
getPeerContainerResourceJid (containerElement) {
if (localVideoThumbnail.container === containerElement) {
return localVideoThumbnail.getId();
}
var i = containerElement.id.indexOf('participant_');
if (i >= 0)
return containerElement.id.substring(i + 12);
},
/** /**
* On audio muted event. * On audio muted event.
*/ */
@ -671,7 +671,7 @@ var VideoLayout = {
// Handle LastN/local LastN changes. // Handle LastN/local LastN changes.
$('#remoteVideos>span').each(function( index, element ) { $('#remoteVideos>span').each(function( index, element ) {
var resourceJid = VideoLayout.getPeerContainerResourceJid(element); var resourceJid = getPeerContainerResourceId(element);
// We do not want to process any logic for our own(local) video // We do not want to process any logic for our own(local) video
// because the local participant is never in the lastN set. // because the local participant is never in the lastN set.