UNPKG

remotion

Version:

Make videos programmatically

30 lines (29 loc) 895 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useSingletonAudioContext = void 0; const react_1 = require("react"); const log_1 = require("../log"); let warned = false; const warnOnce = (logLevel) => { if (warned) { return; } warned = true; // Don't pullute logs if in SSR if (typeof window !== 'undefined') { log_1.Log.warn(logLevel, 'AudioContext is not supported in this browser'); } }; const useSingletonAudioContext = (logLevel, latencyHint) => { const audioContext = (0, react_1.useMemo)(() => { if (typeof AudioContext === 'undefined') { warnOnce(logLevel); return null; } return new AudioContext({ latencyHint, }); }, [logLevel, latencyHint]); return audioContext; }; exports.useSingletonAudioContext = useSingletonAudioContext;