UNPKG

@react-av/editor

Version:

Editor Timeline Components built on React AV.

16 lines 647 B
import { MediaReadyState, useMediaElement, useMediaReadyState } from "@react-av/core"; import { useEffect } from "react"; export function VideoRatio({ fallback, onAspectRatio }) { const video = useMediaElement(); const ready = useMediaReadyState(); useEffect(() => { if ((ready < MediaReadyState.HAVE_METADATA) || !video || video.nodeName !== 'VIDEO') { onAspectRatio(fallback); return; } const { videoWidth, videoHeight } = video; onAspectRatio(videoWidth / videoHeight); }, [video, ready, onAspectRatio, fallback]); return null; } //# sourceMappingURL=VideoRatio.js.map