1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-22 08:35:57 +01:00

Hide peers with no video by default.

Now that we have an indicator in the users list, it is reasonable
to hide audio-ony peers by default.
This commit is contained in:
Juliusz Chroboczek 2022-09-16 19:10:01 +02:00
parent db30b052f9
commit 1bce623080
3 changed files with 54 additions and 2 deletions

View file

@ -905,6 +905,10 @@ h1 {
border: 2px solid #610a86; border: 2px solid #610a86;
} }
.peer-hidden {
display: none;
}
.media { .media {
width: 100%; width: 100%;
max-height: calc(var(--vh, 1vh) * 100 - 76px); max-height: calc(var(--vh, 1vh) * 100 - 76px);

View file

@ -242,6 +242,10 @@
<label for="activitybox">Activity detection</label> <label for="activitybox">Activity detection</label>
</form> </form>
<form>
<input id="displayallbox" type="checkbox"/>
<label for="displayallbox">Display audio-only users</label>
</form>
</fieldset> </fieldset>
</div> </div>
</div> </div>

View file

@ -41,6 +41,7 @@ let token = null;
* @property {string} [send] * @property {string} [send]
* @property {string} [request] * @property {string} [request]
* @property {boolean} [activityDetection] * @property {boolean} [activityDetection]
* @property {boolean} [displayAll]
* @property {Array.<number>} [resolution] * @property {Array.<number>} [resolution]
* @property {boolean} [mirrorView] * @property {boolean} [mirrorView]
* @property {boolean} [blackboardMode] * @property {boolean} [blackboardMode]
@ -219,6 +220,13 @@ function reflectSettings() {
store = true; store = true;
} }
if(settings.hasOwnProperty('displayAll')) {
getInputElement('displayallbox').checked = settings.displayAll;
} else {
settings.displayAll = getInputElement('displayallbox').checked;
store = true;
}
if(settings.hasOwnProperty('preprocessing')) { if(settings.hasOwnProperty('preprocessing')) {
getInputElement('preprocessingbox').checked = settings.preprocessing; getInputElement('preprocessingbox').checked = settings.preprocessing;
} else { } else {
@ -659,6 +667,18 @@ getInputElement('activitybox').onchange = function(e) {
} }
}; };
getInputElement('displayallbox').onchange = function(e) {
if(!(this instanceof HTMLInputElement))
throw new Error('Unexpected type for this');
updateSettings({displayAll: this.checked});
for(let id in serverConnection.down) {
let c = serverConnection.down[id];
let elt = document.getElementById('peer-' + c.localId);
showHideMedia(c, elt);
}
};
/** /**
* @this {Stream} * @this {Stream}
* @param {Object<string,any>} stats * @param {Object<string,any>} stats
@ -1678,16 +1698,17 @@ function scheduleReconsiderDownRate() {
* controls will be created. * controls will be created.
*/ */
async function setMedia(c, mirror, video) { async function setMedia(c, mirror, video) {
let peersdiv = document.getElementById('peers');
let div = document.getElementById('peer-' + c.localId); let div = document.getElementById('peer-' + c.localId);
if(!div) { if(!div) {
div = document.createElement('div'); div = document.createElement('div');
div.id = 'peer-' + c.localId; div.id = 'peer-' + c.localId;
div.classList.add('peer'); div.classList.add('peer');
let peersdiv = document.getElementById('peers');
peersdiv.appendChild(div); peersdiv.appendChild(div);
} }
showHideMedia(c, div)
let media = /** @type {HTMLVideoElement} */ let media = /** @type {HTMLVideoElement} */
(document.getElementById('media-' + c.localId)); (document.getElementById('media-' + c.localId));
if(!media) { if(!media) {
@ -1745,6 +1766,29 @@ async function setMedia(c, mirror, video) {
} }
} }
/**
* @param {Stream} c
* @param {HTMLElement} elt
*/
function showHideMedia(c, elt) {
let display = c.up || getSettings().displayAll;
if(!display && c.stream) {
let tracks = c.stream.getTracks();
for(let i = 0; i < tracks.length; i++) {
let t = tracks[i];
if(t.kind === 'video') {
display = true;
break;
}
}
}
if(display)
elt.classList.remove('peer-hidden');
else
elt.classList.add('peer-hidden');
}
/** /**
* resetMedia resets the source stream of the media element associated * resetMedia resets the source stream of the media element associated
* with c. This has the side-effect of resetting any frozen frames. * with c. This has the side-effect of resetting any frozen frames.