1
Fork 0

Add Unshare button on each shared video and remove global unshare screen button

This commit is contained in:
Alain Takoudjou 2021-03-29 20:44:24 +02:00 committed by Juliusz Chroboczek
parent 3ba2394be7
commit b08a2e3943
3 changed files with 47 additions and 18 deletions

View File

@ -478,7 +478,10 @@ textarea.form-reply {
.top-video-controls { .top-video-controls {
text-align: right; text-align: right;
bottom: inherit; bottom: inherit;
top: 5px; top: 0;
line-height: 1.1;
font-size: 1.3em;
text-shadow: 1px 1px 2px rgb(90 86 86);
} }
.controls-button { .controls-button {
@ -512,7 +515,7 @@ textarea.form-reply {
cursor: pointer; cursor: pointer;
} }
.video-controls span:last-child { .video-controls span:last-child, .top-video-controls span:last-child {
margin-right: 0; margin-right: 0;
} }
@ -530,6 +533,10 @@ textarea.form-reply {
font-size: 0.85em; font-size: 0.85em;
} }
.video-controls .video-stop {
color: #d03e3e;
}
.video-controls span.disabled, .video-controls span.disabled:hover, .top-video-controls span.disabled:hover{ .video-controls span.disabled, .video-controls span.disabled:hover, .top-video-controls span.disabled:hover{
opacity: .2; opacity: .2;
color: #c8c8c8 color: #c8c8c8
@ -1233,6 +1240,10 @@ header .collapse {
margin-bottom: 60px; margin-bottom: 60px;
} }
.top-video-controls {
opacity: 1;
}
.login-container { .login-container {
position: fixed; position: fixed;
height: calc(var(--vh, 1vh) * 100 - 56px); height: calc(var(--vh, 1vh) * 100 - 56px);

View File

@ -60,12 +60,6 @@
<label>Share Screen</label> <label>Share Screen</label>
</div> </div>
</li> </li>
<li>
<div id="unsharebutton" class="invisible nav-link nav-button nav-cancel">
<span><i class="fas fa-window-close" aria-hidden="true"></i></span>
<label>Unshare Screen</label>
</div>
</li>
<li> <li>
<div id="stopvideobutton" class="invisible nav-link nav-button nav-cancel"> <div id="stopvideobutton" class="invisible nav-link nav-button nav-cancel">
<span><i class="fas fa-window-close" aria-hidden="true"></i></span> <span><i class="fas fa-window-close" aria-hidden="true"></i></span>
@ -265,6 +259,14 @@
</div> </div>
</div> </div>
</div> </div>
<div id="topvideocontrols-template" class="invisible">
<div class="top-video-controls">
<div class="controls-button controls-right">
<span class="close-icon video-stop" title="Stop video">
</span>
</div>
</div>
</div>
<script src="/protocol.js" defer></script> <script src="/protocol.js" defer></script>
<script src="/scripts/toastify.js" defer></script> <script src="/scripts/toastify.js" defer></script>

View File

@ -420,7 +420,6 @@ function setButtonsVisibility() {
let connected = serverConnection && serverConnection.socket; let connected = serverConnection && serverConnection.socket;
let permissions = serverConnection.permissions; let permissions = serverConnection.permissions;
let local = !!findUpMedia('local'); let local = !!findUpMedia('local');
let share = !!findUpMedia('screenshare');
let video = !!findUpMedia('video'); let video = !!findUpMedia('video');
let canWebrtc = !(typeof RTCPeerConnection === 'undefined'); let canWebrtc = !(typeof RTCPeerConnection === 'undefined');
let canFile = let canFile =
@ -440,7 +439,6 @@ function setButtonsVisibility() {
// allow multiple shared documents // allow multiple shared documents
setVisibility('sharebutton', canWebrtc && permissions.present && setVisibility('sharebutton', canWebrtc && permissions.present &&
('getDisplayMedia' in navigator.mediaDevices)); ('getDisplayMedia' in navigator.mediaDevices));
setVisibility('unsharebutton', share);
setVisibility('stopvideobutton', video); setVisibility('stopvideobutton', video);
@ -516,12 +514,6 @@ document.getElementById('sharebutton').onclick = function(e) {
addShareMedia(); addShareMedia();
}; };
document.getElementById('unsharebutton').onclick = function(e) {
e.preventDefault();
closeUpMediaKind('screenshare');
resizePeers();
};
document.getElementById('stopvideobutton').onclick = function(e) { document.getElementById('stopvideobutton').onclick = function(e) {
e.preventDefault(); e.preventDefault();
closeUpMediaKind('video'); closeUpMediaKind('video');
@ -1428,10 +1420,18 @@ function addCustomControls(media, container, c) {
let template = let template =
document.getElementById('videocontrols-template').firstElementChild; document.getElementById('videocontrols-template').firstElementChild;
let toptemplate =
document.getElementById('topvideocontrols-template').firstElementChild;
controls = cloneHTMLElement(template); controls = cloneHTMLElement(template);
controls.id = 'controls-' + c.localId; controls.id = 'controls-' + c.localId;
let topcontrols = cloneHTMLElement(toptemplate);
topcontrols.id = 'topcontrols-' + c.localId;
let volume = getVideoButton(controls, 'volume'); let volume = getVideoButton(controls, 'volume');
let stopsharing = getVideoButton(topcontrols, 'video-stop');
if (c.kind !== "screenshare") {
stopsharing.remove();
}
if(c.kind === 'local') { if(c.kind === 'local') {
volume.remove(); volume.remove();
} else { } else {
@ -1440,8 +1440,9 @@ function addCustomControls(media, container, c) {
getVideoButton(controls, "volume-slider")); getVideoButton(controls, "volume-slider"));
} }
container.appendChild(topcontrols);
container.appendChild(controls); container.appendChild(controls);
registerControlHandlers(media, container); registerControlHandlers(media, container, c);
} }
/** /**
@ -1474,8 +1475,9 @@ function setVolumeButton(muted, button, slider) {
/** /**
* @param {HTMLVideoElement} media * @param {HTMLVideoElement} media
* @param {HTMLElement} container * @param {HTMLElement} container
* @param {Stream} c
*/ */
function registerControlHandlers(media, container) { function registerControlHandlers(media, container, c) {
let play = getVideoButton(container, 'video-play'); let play = getVideoButton(container, 'video-play');
if(play) { if(play) {
play.onclick = function(event) { play.onclick = function(event) {
@ -1484,6 +1486,20 @@ function registerControlHandlers(media, container) {
}; };
} }
let stop = getVideoButton(container, 'video-stop');
if(stop) {
stop.onclick = function(event) {
event.preventDefault();
try {
c.close(true);
delMedia(c.localId);
} catch(e) {
console.error(e);
displayError(e);
}
};
}
let volume = getVideoButton(container, 'volume'); let volume = getVideoButton(container, 'volume');
if (volume) { if (volume) {
volume.onclick = function(event) { volume.onclick = function(event) {