Files
v10/apps/sandbox/templates/react-audio/main.tsx
T

39 lines
1.4 KiB
TypeScript

import '@app/styles.css';
import { AudioProvider } from '@app/shared/react/providers';
import { AudioSkinComponent } from '@app/shared/react/skins';
import { useAutoplay } from '@app/shared/react/use-autoplay';
import { useLoop } from '@app/shared/react/use-loop';
import { useMuted } from '@app/shared/react/use-muted';
import { usePreload } from '@app/shared/react/use-preload';
import { useSkin } from '@app/shared/react/use-skin';
import { useSource } from '@app/shared/react/use-source';
import { SOURCES } from '@app/shared/sources';
import type { Styling } from '@app/types';
import { Audio } from '@videojs/react/audio';
import { useMemo } from 'react';
import { createRoot } from 'react-dom/client';
function readStyling(): Styling {
return new URLSearchParams(location.search).get('styling') === 'tailwind' ? 'tailwind' : 'css';
}
function App() {
const skin = useSkin();
const source = useSource(true);
const styling = useMemo(readStyling, []);
const autoplay = useAutoplay();
const muted = useMuted();
const loop = useLoop();
const preload = usePreload();
return (
<AudioProvider>
<AudioSkinComponent skin={skin} styling={styling} className="w-full max-w-xl mx-auto">
<Audio src={SOURCES[source].url} autoPlay={autoplay} muted={muted} loop={loop} preload={preload} />
</AudioSkinComponent>
</AudioProvider>
);
}
createRoot(document.getElementById('root')!).render(<App />);