From f20f32f6a61d0ad58abbfdaad2b99f6799f9a4a1 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Mon, 14 Nov 2022 22:05:25 -0600 Subject: [PATCH] feat: Video focusing (#71) * feat: focus video on click --- src/components/Room/PeerVideo.tsx | 31 ++++- src/components/Room/RoomVideoDisplay.tsx | 164 +++++++++++++++++------ 2 files changed, 152 insertions(+), 43 deletions(-) diff --git a/src/components/Room/PeerVideo.tsx b/src/components/Room/PeerVideo.tsx index e8ae900..149fe73 100644 --- a/src/components/Room/PeerVideo.tsx +++ b/src/components/Room/PeerVideo.tsx @@ -2,12 +2,22 @@ import { useEffect, useRef } from 'react' import Paper from '@mui/material/Paper' import { PeerNameDisplay } from 'components/PeerNameDisplay' +import { VideoStreamType } from 'models/chat' + +import { SelectedPeerStream } from './RoomVideoDisplay' interface PeerVideoProps { isSelfVideo?: boolean numberOfVideos: number + onVideoClick?: ( + userId: string, + videoStreamType: VideoStreamType, + videoStream: MediaStream + ) => void + selectedPeerStream: SelectedPeerStream | null userId: string videoStream: MediaStream + videoStreamType: VideoStreamType } // Adapted from https://www.geeksforgeeks.org/find-the-next-perfect-square-greater-than-a-given-number/ @@ -20,8 +30,11 @@ const nextPerfectSquare = (base: number) => { export const PeerVideo = ({ isSelfVideo, numberOfVideos, + onVideoClick, userId, + selectedPeerStream, videoStream, + videoStreamType, }: PeerVideoProps) => { const videoRef = useRef(null) @@ -35,6 +48,10 @@ export const PeerVideo = ({ const sizePercent = 100 / Math.sqrt(nextPerfectSquare(numberOfVideos - 1)) + const handleVideoClick = () => { + onVideoClick?.(userId, videoStreamType, videoStream) + } + return (