MCPcopy Create free account
hub / github.com/cloudflare/meet / useVideoDimensions

Function useVideoDimensions

app/hooks/useVideoDimensions.ts:3–21  ·  view source on GitHub ↗
(ref: RefObject<HTMLVideoElement>)

Source from the content-addressed store, hash-verified

1import { useEffect, useState, type RefObject } from 'react'
2
3export function useVideoDimensions(ref: RefObject<HTMLVideoElement>) {
4 const [videoHeight, setVideoHeight] = useState(ref.current?.videoHeight ?? 0)
5 const [videoWidth, setVideoWidth] = useState(ref.current?.videoHeight ?? 0)
6
7 useEffect(() => {
8 const video = ref.current
9 if (!video) return
10 const handler = () => {
11 setVideoHeight(video.videoHeight)
12 setVideoWidth(video.videoWidth)
13 }
14 video.addEventListener('resize', handler)
15 return () => {
16 video.removeEventListener('resize', handler)
17 }
18 }, [ref])
19
20 return { videoHeight, videoWidth }
21}

Callers 1

Participant.tsxFile · 0.90

Calls 2

addEventListenerMethod · 0.80
removeEventListenerMethod · 0.80

Tested by

no test coverage detected