[mirotalksfu] - improve aspect ratio

هذا الالتزام موجود في:
Miroslav Pejic
2021-12-29 22:35:55 +01:00
الأصل b2b32f65a2
التزام ede19a6ddd
3 ملفات معدلة مع 15 إضافات و10 حذوفات

عرض الملف

@@ -745,8 +745,7 @@ function handleSelects() {
BtnsAspectRatio.onchange = () => { BtnsAspectRatio.onchange = () => {
setAspectRatio(BtnsAspectRatio.value); setAspectRatio(BtnsAspectRatio.value);
}; };
// Video aspect ratio for Mobile device 4:3 on Desktop 16:9 BtnsAspectRatio.selectedIndex = 0; // default
BtnsAspectRatio.selectedIndex = DetectRTC.isMobileDevice ? 0 : 1;
setAspectRatio(BtnsAspectRatio.selectedIndex); setAspectRatio(BtnsAspectRatio.selectedIndex);
BtnsBarPosition.onchange = () => { BtnsBarPosition.onchange = () => {

عرض الملف

@@ -1,12 +1,15 @@
'use strict'; 'use strict';
// aspect 0 1 2 3 let customRatio = true;
let ratios = ['4:3', '16:9', '1:1', '1:2'];
let aspect = 1; // aspect 0 1 2 3 4
let ratios = ['0:0', '4:3', '16:9', '1:1', '1:2'];
let aspect = 0;
let ratio = getAspectRatio(); let ratio = getAspectRatio();
function getAspectRatio() { function getAspectRatio() {
customRatio = aspect == 0 ? true : false;
var ratio = ratios[aspect].split(':'); var ratio = ratios[aspect].split(':');
return ratio[1] / ratio[0]; return ratio[1] / ratio[0];
} }
@@ -18,6 +21,7 @@ function setAspectRatio(i) {
} }
function Area(Increment, Count, Width, Height, Margin = 10) { function Area(Increment, Count, Width, Height, Margin = 10) {
ratio = customRatio ? 0.75 : ratio;
let i = 0; let i = 0;
let w = 0; let w = 0;
let h = Increment * ratio + Margin * 2; let h = Increment * ratio + Margin * 2;
@@ -34,7 +38,7 @@ function Area(Increment, Count, Width, Height, Margin = 10) {
} }
function resizeVideoMedia() { function resizeVideoMedia() {
let Margin = 2; let Margin = 3;
let Scenary = document.getElementById('videoMediaContainer'); let Scenary = document.getElementById('videoMediaContainer');
let Width = Scenary.offsetWidth - Margin * 2; let Width = Scenary.offsetWidth - Margin * 2;
let Height = Scenary.offsetHeight - Margin * 2; let Height = Scenary.offsetHeight - Margin * 2;
@@ -57,6 +61,7 @@ function resizeVideoMedia() {
} }
function setWidth(width, margin) { function setWidth(width, margin) {
ratio = customRatio ? 0.68 : ratio;
let Cameras = document.getElementsByClassName('Camera'); let Cameras = document.getElementsByClassName('Camera');
for (let s = 0; s < Cameras.length; s++) { for (let s = 0; s < Cameras.length; s++) {
Cameras[s].style.width = width + 'px'; Cameras[s].style.width = width + 'px';

عرض الملف

@@ -231,10 +231,11 @@ access to use this app.
<p>Aspect ratio:</p> <p>Aspect ratio:</p>
<br /> <br />
<select id="BtnsAspectRatio" class="form-select text-light bg-dark"> <select id="BtnsAspectRatio" class="form-select text-light bg-dark">
<option value="0">4:3</option> <option value="0">default</option>
<option value="1">16:9</option> <option value="1">4:3</option>
<option value="2">1:1</option> <option value="2">16:9</option>
<option value="3">1:2</option> <option value="3">1:1</option>
<option value="4">1:2</option>
</select> </select>
<br /> <br />
<p>Buttons bar:</p> <p>Buttons bar:</p>