From 7e39f05491eb9384c99a546de3923b77065d5854 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Wed, 6 Mar 2024 22:37:11 -0800 Subject: [PATCH] scaling video calls --- net/web/src/constants/Colors.js | 4 ++ net/web/src/session/Session.jsx | 66 ++++++--------------------- net/web/src/session/Session.styled.js | 25 ++++++++-- 3 files changed, 40 insertions(+), 55 deletions(-) diff --git a/net/web/src/constants/Colors.js b/net/web/src/constants/Colors.js index 78fdc609..feb68f97 100644 --- a/net/web/src/constants/Colors.js +++ b/net/web/src/constants/Colors.js @@ -40,6 +40,8 @@ export const Colors = { }; export const LightTheme = { + remoteArea: '#080808', + localArea: '#888888', splashArea: '#8fbea7', baseArea: '#8fbea7', frameArea: '#e4e4e4', @@ -77,6 +79,8 @@ export const LightTheme = { }; export const DarkTheme = { + remoteArea: '#080808', + localArea: '#888888', splashArea: '#4c4c4c', baseArea: '#080808', frameArea: '#0a0a0a', diff --git a/net/web/src/session/Session.jsx b/net/web/src/session/Session.jsx index f2483f08..34472089 100644 --- a/net/web/src/session/Session.jsx +++ b/net/web/src/session/Session.jsx @@ -21,14 +21,18 @@ import { SettingsContext } from 'context/SettingsContext'; import avatar from 'images/avatar.png'; +function getDim() { + if (window.innerWidth > window.innerHeight) { + return window.innerHeight / 2; + } + return window.innerWidth / 2; +} + export function Session() { const { state, actions } = useSession(); const settings = useContext(SettingsContext); const [ringing, setRinging] = useState([]); - const [callWidth, setCallWidth] = useState(256); - const [callHeight, setCallHeight] = useState(256); - const [callModal, setCallModal] = useState({ width: 256, height: 256, offset: 0 }); const remote = useRef(); const local = useRef(); @@ -61,48 +65,8 @@ export function Session() { // eslint-disable-next-line }, [state.ringing]); - useEffect(() => { - if (!state.remoteVideo) { - setCallModal({ width: 256 + 12, height: 256 + 12, offset: 0 }); - } - else { - setCallModal({ width: callWidth + 12, height: callHeight + 12, offset: ((268 - callHeight) / 2) }); - } - - }, [callWidth, callHeight, state.remoteVideo]) - useEffect(() => { if (remote.current) { - remote.current.onloadedmetadata = (ev) => { - - const { videoWidth, videoHeight } = ev.target || { videoWidth: 256, videoHeight: 256 } - if ((window.innerWidth * 8) / 10 < videoWidth) { - const scaledWidth = window.innerWidth * 8 / 10; - const scaledHeight = videoHeight * (scaledWidth / videoWidth) - if ((window.innerHeight * 8) / 10 < scaledHeight) { - const height = (window.innerHeight * 8) / 10; - setCallHeight(height); - setCallWidth(videoWidth * (height / videoHeight)); - } - else { - setCallHeight(scaledHeight); - setCallWidth(scaledWidth); - } - } - else if ((window.innerHeight * 8) / 10 < videoHeight) { - const height = (window.innerHeight * 8) / 10; - setCallHeight(height); - setCallWidth(videoWidth * (height / videoHeight)); - } - else if (videoHeight < 72 || videoWidth < 72) { - setCallHeight(72); - setCallWidth(72); - } - else { - setCallHeight(videoHeight); - setCallWidth(videoWidth); - } - }; remote.current.srcObject = state.remoteStream; remote.current.load(); remote.current.play(); @@ -119,10 +83,6 @@ export function Session() { } }, [state.localStream]); - useEffect(() => { - console.log("DIM: ", callWidth, callHeight); - }, [callWidth, callHeight]); - const closeAccount = () => { actions.closeProfile(); actions.closeAccount(); @@ -347,7 +307,7 @@ export function Session() { - +
@@ -362,13 +322,17 @@ export function Session() {
)} { state.remoteStream && ( -