UNPKG

@react-av/editor

Version:

Editor Timeline Components built on React AV.

19 lines 748 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VideoRatio = VideoRatio; const core_1 = require("@react-av/core"); const react_1 = require("react"); function VideoRatio({ fallback, onAspectRatio }) { const video = (0, core_1.useMediaElement)(); const ready = (0, core_1.useMediaReadyState)(); (0, react_1.useEffect)(() => { if ((ready < core_1.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