Commit 58ba37d8 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement stopping of videos.

parent 2c9ee2f4
...@@ -65,6 +65,12 @@ ...@@ -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>
......
...@@ -393,6 +393,7 @@ function setButtonsVisibility() { ...@@ -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() { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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) { ...@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment