1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-23 00:55:58 +01:00

Implement stopping of videos.

This commit is contained in:
Juliusz Chroboczek 2020-11-24 22:41:43 +01:00
parent 2c9ee2f431
commit 58ba37d8da
2 changed files with 22 additions and 0 deletions

View file

@ -65,6 +65,12 @@
<label>Unshare Screen</label> <label>Unshare Screen</label>
</div> </div>
</li> </li>
<li>
<div id="stopvideobutton" class="invisible nav-link nav-button nav-cancel">
<span><i class="fas fa-window-close" aria-hidden="true"></i></span>
<label>Stop Video</label>
</div>
</li>
<li> <li>
<div class="nav-button nav-link invisible" id="user"> <div class="nav-button nav-link invisible" id="user">
<span><i class="fas fa-user dropbtn" aria-hidden="true"></i></span> <span><i class="fas fa-user dropbtn" aria-hidden="true"></i></span>

View file

@ -393,6 +393,7 @@ function setButtonsVisibility() {
let permissions = serverConnection.permissions; let permissions = serverConnection.permissions;
let local = !!findUpMedia('local'); let local = !!findUpMedia('local');
let share = !!findUpMedia('screenshare'); let share = !!findUpMedia('screenshare');
let video = !!findUpMedia('video');
// don't allow multiple presentations // don't allow multiple presentations
setVisibility('presentbutton', permissions.present && !local); setVisibility('presentbutton', permissions.present && !local);
@ -403,6 +404,8 @@ function setButtonsVisibility() {
('getDisplayMedia' in navigator.mediaDevices)); ('getDisplayMedia' in navigator.mediaDevices));
setVisibility('unsharebutton', share); setVisibility('unsharebutton', share);
setVisibility('stopvideobutton', video);
setVisibility('mediaoptions', permissions.present); setVisibility('mediaoptions', permissions.present);
} }
@ -467,6 +470,12 @@ document.getElementById('unsharebutton').onclick = function(e) {
resizePeers(); resizePeers();
} }
document.getElementById('stopvideobutton').onclick = function(e) {
e.preventDefault();
delUpMediaKind('video');
resizePeers();
}
/** @returns {number} */ /** @returns {number} */
function getMaxVideoThroughput() { function getMaxVideoThroughput() {
let v = getSettings().send; let v = getSettings().send;
@ -528,6 +537,7 @@ getInputElement('fileinput').onchange = function(e) {
let files = input.files; let files = input.files;
for(let i = 0; i < files.length; i++) for(let i = 0; i < files.length; i++)
addFileMedia(files[i]); addFileMedia(files[i]);
input.value = '';
} }
/** /**
@ -900,6 +910,7 @@ async function addFileMedia(file) {
}; };
setMedia(c, true, video); setMedia(c, true, video);
video.play(); video.play();
setButtonsVisibility()
} }
/** /**
@ -1190,6 +1201,11 @@ function delMedia(id) {
let media = /** @type{HTMLVideoElement} */ let media = /** @type{HTMLVideoElement} */
(document.getElementById('media-' + id)); (document.getElementById('media-' + id));
if(media.src) {
URL.revokeObjectURL(media.src);
media.src = null;
}
media.srcObject = null; media.srcObject = null;
mediadiv.removeChild(peer); mediadiv.removeChild(peer);