From bdefab22d6f5e2e222d091801c43784f70dd960e Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Wed, 29 Dec 2021 14:18:07 +0100 Subject: [PATCH] [mirotalksfu] - add possibility to set Video aspect ratio --- public/js/Room.js | 6 ++++++ public/js/VideoGrid.js | 23 ++++++++++++++++++++--- public/view/Room.html | 9 +++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/public/js/Room.js b/public/js/Room.js index 6e53d8f..04b789d 100644 --- a/public/js/Room.js +++ b/public/js/Room.js @@ -742,9 +742,15 @@ function handleSelects() { rc.closeThenProduce(RoomClient.mediaType.video, videoSelect.value); }; // styling + BtnsAspectRatio.onchange = () => { + setAspectRatio(BtnsAspectRatio.value); + }; + BtnsAspectRatio.selectedIndex = '1'; + BtnsBarPosition.onchange = () => { rc.changeBtnsBarPosition(BtnsBarPosition.value); }; + // whiteboard options wbDrawingColorEl.onchange = () => { wbCanvas.freeDrawingBrush.color = wbDrawingColorEl.value; diff --git a/public/js/VideoGrid.js b/public/js/VideoGrid.js index 1b1edf6..46a5847 100644 --- a/public/js/VideoGrid.js +++ b/public/js/VideoGrid.js @@ -1,13 +1,30 @@ 'use strict'; +// aspect 0 1 2 3 +let ratios = ['4:3', '16:9', '1:1', '1:2']; +let aspect = 1; + +let ratio = getAspectRatio(); + +function getAspectRatio() { + var ratio = ratios[aspect].split(':'); + return ratio[1] / ratio[0]; +} + +function setAspectRatio(i) { + aspect = i; + ratio = getAspectRatio(); + resizeVideoMedia(); +} + function Area(Increment, Count, Width, Height, Margin = 10) { let i = 0; let w = 0; - let h = Increment * 0.75 + Margin * 2; + let h = Increment * ratio + Margin * 2; while (i < Count) { if (w + Increment > Width) { w = 0; - h = h + Increment * 0.75 + Margin * 2; + h = h + Increment * ratio + Margin * 2; } w = w + Increment + Margin * 2; i++; @@ -44,7 +61,7 @@ function setWidth(width, margin) { for (let s = 0; s < Cameras.length; s++) { Cameras[s].style.width = width + 'px'; Cameras[s].style.margin = margin + 'px'; - Cameras[s].style.height = width * 0.7 + 'px'; + Cameras[s].style.height = width * ratio + 'px'; } } diff --git a/public/view/Room.html b/public/view/Room.html index 192bf4f..846f224 100644 --- a/public/view/Room.html +++ b/public/view/Room.html @@ -227,6 +227,15 @@ access to use this app.
+
+

Aspect ratio:

+
+

Buttons bar: