remotion
Version:
Render videos in React
29 lines • 1.88 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Audio = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const sequencing_1 = require("../sequencing");
const validate_media_props_1 = require("../validate-media-props");
const validate_start_from_props_1 = require("../validate-start-from-props");
const AudioForDevelopment_1 = require("./AudioForDevelopment");
const AudioForRendering_1 = require("./AudioForRendering");
const AudioRefForwardingFunction = (props, ref) => {
const { startFrom, endAt, ...otherProps } = props;
const onError = react_1.useCallback(() => {
throw new Error(`Could not play video with src ${otherProps.src}`);
}, [otherProps.src]);
if (typeof startFrom !== 'undefined' || typeof endAt !== 'undefined') {
validate_start_from_props_1.validateStartFromProps(startFrom, endAt);
const startFromFrameNo = startFrom !== null && startFrom !== void 0 ? startFrom : 0;
const endAtFrameNo = endAt !== null && endAt !== void 0 ? endAt : Infinity;
return (jsx_runtime_1.jsx(sequencing_1.Sequence, Object.assign({ layout: "none", from: 0 - startFromFrameNo, showInTimeline: false, durationInFrames: endAtFrameNo }, { children: jsx_runtime_1.jsx(exports.Audio, Object.assign({}, otherProps, { ref: ref }), void 0) }), void 0));
}
validate_media_props_1.validateMediaProps(props, 'Audio');
if (process.env.NODE_ENV === 'development') {
return jsx_runtime_1.jsx(AudioForDevelopment_1.AudioForDevelopment, Object.assign({}, props, { ref: ref, onError: onError }), void 0);
}
return jsx_runtime_1.jsx(AudioForRendering_1.AudioForRendering, Object.assign({}, props, { ref: ref, onError: onError }), void 0);
};
exports.Audio = react_1.forwardRef(AudioRefForwardingFunction);
//# sourceMappingURL=Audio.js.map