Commit 6a9ab969 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Use default controls for streamed video.

parent 58ba37d8
...@@ -892,6 +892,7 @@ async function addFileMedia(file) { ...@@ -892,6 +892,7 @@ async function addFileMedia(file) {
let url = URL.createObjectURL(file); let url = URL.createObjectURL(file);
let video = document.createElement('video'); let video = document.createElement('video');
video.src = url; video.src = url;
video.controls = true;
/** @ts-ignore */ /** @ts-ignore */
let stream = video.captureStream(); let stream = video.captureStream();
...@@ -1042,42 +1043,43 @@ function setMedia(c, isUp, video) { ...@@ -1042,42 +1043,43 @@ function setMedia(c, isUp, video) {
div.appendChild(label); div.appendChild(label);
} }
let template = document.getElementById('videocontrols-template') if(!video) {
.firstElementChild; let template = document.getElementById('videocontrols-template')
let top_template = document.getElementById('top-videocontrols-template') .firstElementChild;
.firstElementChild; let top_template = document.getElementById('top-videocontrols-template')
.firstElementChild;
let top_controls = document.getElementById('topcontrols-' + c.id);
if(template && !top_controls) { let top_controls = document.getElementById('topcontrols-' + c.id);
top_controls = /** @type{HTMLElement} */(top_template.cloneNode(true)); if(template && !top_controls) {
top_controls.id = 'topcontrols-' + c.id; top_controls = /** @type{HTMLElement} */(top_template.cloneNode(true));
div.appendChild(top_controls); top_controls.id = 'topcontrols-' + c.id;
} div.appendChild(top_controls);
let controls = document.getElementById('controls-' + c.id);
if(template && !controls) {
controls = /** @type{HTMLElement} */(template.cloneNode(true));
controls.id = 'controls-' + c.id;
div.appendChild(controls);
let volume = controls.querySelector(".fa-volume-up");
if(media.muted) {
if (volume) {
volume.classList.remove("fa-volume-up");
volume.classList.add("fa-volume-off");
}
} }
let camera = controls.querySelector("span.camera"); let controls = document.getElementById('controls-' + c.id);
if (local_media && local_media.kind === "local") { if(template && !controls) {
if (!settings.video) { controls = /** @type{HTMLElement} */(template.cloneNode(true));
if (camera) controls.id = 'controls-' + c.id;
camera.classList.add("camera-off"); div.appendChild(controls);
let volume = controls.querySelector(".fa-volume-up");
if(media.muted) {
if (volume) {
volume.classList.remove("fa-volume-up");
volume.classList.add("fa-volume-off");
}
} }
volume.parentElement.remove(); let camera = controls.querySelector("span.camera");
} else if (local_media && local_media.kind === "local") {
camera.remove(); if (!settings.video) {
} if (camera)
camera.classList.add("camera-off");
}
volume.parentElement.remove();
} else
camera.remove();
}
if(!video)
media.srcObject = c.stream; media.srcObject = c.stream;
}
setLabel(c); setLabel(c);
setMediaStatus(c); setMediaStatus(c);
...@@ -1142,29 +1144,33 @@ function registerControlEvent(peerid) { ...@@ -1142,29 +1144,33 @@ function registerControlEvent(peerid) {
} }
let pip = /** @type {HTMLElement} */(peer.querySelector("span.pip")); let pip = /** @type {HTMLElement} */(peer.querySelector("span.pip"));
/** @ts-ignore */ if(pip) {
if(HTMLVideoElement.prototype.requestPictureInPicture) { /** @ts-ignore */
pip.onclick = function(event) { if(HTMLVideoElement.prototype.requestPictureInPicture) {
event.preventDefault(); pip.onclick = function(event) {
let pip = /** @type{HTMLElement} */(event.target); event.preventDefault();
let video = getParentVideo(pip); let pip = /** @type{HTMLElement} */(event.target);
videoPIP(video); let video = getParentVideo(pip);
}; videoPIP(video);
} else { };
pip.style.display = 'none'; } else {
pip.style.display = 'none';
}
} }
let fs = /** @type {HTMLElement} */(peer.querySelector("span.fullscreen")); let fs = /** @type {HTMLElement} */(peer.querySelector("span.fullscreen"));
fs.onclick = function(event) { if(fs) {
event.preventDefault(); fs.onclick = function(event) {
let fs = /** @type {HTMLElement} */(event.target); event.preventDefault();
let video = getParentVideo(fs); let fs = /** @type {HTMLElement} */(event.target);
if(video.requestFullscreen) { let video = getParentVideo(fs);
video.requestFullscreen(); if(video.requestFullscreen) {
} else { video.requestFullscreen();
displayWarning("Video Fullscreen not supported!"); } else {
} displayWarning("Video Fullscreen not supported!");
}; }
};
}
let camera = /** @type {HTMLElement} */(peer.querySelector("span.camera")); let camera = /** @type {HTMLElement} */(peer.querySelector("span.camera"));
if(camera) { if(camera) {
......
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