chore(sandbox): add hls-video to new sandbox setup (NOTE: hls-video H… (#798)

This commit is contained in:
Christian Pillsbury
2026-03-09 19:04:06 -07:00
committed by GitHub
parent c8a4a5990d
commit e417ec3419
7 changed files with 99 additions and 1 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
export const SKINS = ['default', 'minimal'] as const;
export const PLATFORMS = ['html', 'react'] as const;
export const STYLINGS = ['css', 'tailwind'] as const;
export const PRESETS = ['video', 'audio', 'background-video'] as const;
export const PRESETS = ['video', 'hls-video', 'audio', 'background-video'] as const;
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sandbox — HTML Video</title>
<link rel="preconnect" href="https://rsms.me/" />
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
<link rel="stylesheet" href="../styles.css" />
</head>
<body class="font-sans">
<div id="root" class="flex justify-center items-center min-h-screen"></div>
<script type="module" src="./main.ts"></script>
</body>
</html>
@@ -0,0 +1,41 @@
import '@videojs/html/video/player';
import '@videojs/html/media/hls-video';
import '@videojs/html/video/skin';
import '@videojs/html/video/minimal-skin';
import { CSS_SKIN_TAGS } from '../shared/html/skin-tags';
import { loadVideoStylesheets } from '../shared/html/stylesheets';
import { getInitialSkin, getInitialSource, onSkinChange, onSourceChange } from '../shared/sandbox-listener';
import type { SourceId } from '../shared/sources';
import { SOURCES } from '../shared/sources';
import type { Skin } from '../types';
const html = String.raw;
let currentSkin: Skin = getInitialSkin();
let currentSource: SourceId = getInitialSource();
function render() {
const tag = CSS_SKIN_TAGS[currentSkin].video;
loadVideoStylesheets(currentSkin);
document.getElementById('root')!.innerHTML = html`
<video-player class="contents">
<${tag} class="w-full aspect-video max-w-4xl mx-auto">
<hls-video slot="media" src="${SOURCES[currentSource].url}"></hls-video>
</${tag}>
</video-player>
`;
}
render();
onSkinChange((skin) => {
currentSkin = skin;
render();
});
onSourceChange((source) => {
currentSource = source;
render();
});
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sandbox — React Video</title>
<link rel="preconnect" href="https://rsms.me/" />
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
<link rel="stylesheet" href="../styles.css" />
</head>
<body class="font-sans">
<div id="root" class="flex justify-center items-center min-h-screen"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
@@ -0,0 +1,24 @@
import '@videojs/react/video/skin.css';
import '@videojs/react/video/minimal-skin.css';
import { HlsVideo } from '@videojs/react/media/hls-video';
import { createRoot } from 'react-dom/client';
import { VideoProvider } from '../shared/react/providers';
import { VideoSkinComponent } from '../shared/react/skins';
import { useSkin } from '../shared/react/use-skin';
import { useSource } from '../shared/react/use-source';
import { SOURCES } from '../shared/sources';
function App() {
const skin = useSkin();
const source = useSource();
return (
<VideoProvider>
<VideoSkinComponent skin={skin} styling="css" className="w-full aspect-video max-w-4xl mx-auto">
<HlsVideo src={SOURCES[source].url} />
</VideoSkinComponent>
</VideoProvider>
);
}
createRoot(document.getElementById('root')!).render(<App />);
@@ -30,6 +30,7 @@ const PLATFORM_LABELS: Record<Platform, string> = {
const PRESET_LABELS: Record<Preset, string> = {
video: 'Video',
'hls-video': 'HlsVideo',
audio: 'Audio',
'background-video': 'Background Video',
};
+2
View File
@@ -27,11 +27,13 @@ export default defineConfig({
input: {
main: resolve(__dirname, 'src/index.html'),
'html-video': resolve(__dirname, 'src/html-video/index.html'),
'html-hls-video': resolve(__dirname, 'src/html-hls-video/index.html'),
'html-audio': resolve(__dirname, 'src/html-audio/index.html'),
'html-video-tailwind': resolve(__dirname, 'src/html-video-tailwind/index.html'),
'html-audio-tailwind': resolve(__dirname, 'src/html-audio-tailwind/index.html'),
'html-background-video': resolve(__dirname, 'src/html-background-video/index.html'),
'react-video': resolve(__dirname, 'src/react-video/index.html'),
'react-hls-video': resolve(__dirname, 'src/react-hls-video/index.html'),
'react-audio': resolve(__dirname, 'src/react-audio/index.html'),
'react-video-tailwind': resolve(__dirname, 'src/react-video-tailwind/index.html'),
'react-audio-tailwind': resolve(__dirname, 'src/react-audio-tailwind/index.html'),