Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/sandbox/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export const PRESETS = [
'dash-video',
'audio',
'background-video',
'vimeo-video',
] as const;
2 changes: 2 additions & 0 deletions apps/sandbox/app/shared/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export const DEFAULT_DASH_SOURCE: SourceId = 'dash-1';

export const BACKGROUND_VIDEO_SRC = 'https://stream.mux.com/Sc89iWAyNkhJ3P1rQ02nrEdCFTnfT01CZ2KmaEcxXfB008/low.mp4';

export const VIMEO_VIDEO_SRC = 'https://vimeo.com/648359100';

/** Returns true when the given source represents a live stream and should use the live-video skin. */
export function isLiveSource(id: SourceId): boolean {
return (SOURCES[id] as { live?: boolean }).live === true;
Expand Down
6 changes: 4 additions & 2 deletions apps/sandbox/app/shell/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Preview } from './preview';
function getPagePath(platform: Platform, preset: Preset): string {
if (platform === 'cdn') return '/cdn/';
if (preset === 'background-video') return `/${platform}-background-video/`;
if (preset === 'vimeo-video') return `/${platform}-vimeo-video/`;
return `/${platform}-${preset}/`;
}

Expand Down Expand Up @@ -113,9 +114,9 @@ export function App() {
}
}, [preset, source, setSource]);

// CDN and background video do not have a Tailwind skin variant.
// CDN, background video, and vimeo video do not have a Tailwind skin variant.
useEffect(() => {
if ((platform === 'cdn' || preset === 'background-video') && styling === 'tailwind') {
if ((platform === 'cdn' || preset === 'background-video' || preset === 'vimeo-video') && styling === 'tailwind') {
setStyling('css');
}
}, [platform, preset, styling]);
Expand Down Expand Up @@ -151,6 +152,7 @@ export function App() {
isSimpleHls={preset.startsWith('simple-hls-')}
isMuxVideo={preset === 'mux-video'}
isMuxAudio={preset === 'mux-audio'}
isVimeoVideo={preset === 'vimeo-video'}
platforms={PLATFORMS}
stylings={STYLINGS}
presets={PRESETS}
Expand Down
7 changes: 5 additions & 2 deletions apps/sandbox/app/shell/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type NavbarProps = {
isSimpleHls: boolean;
isMuxVideo: boolean;
isMuxAudio: boolean;
isVimeoVideo: boolean;
platforms: readonly Platform[];
stylings: readonly Styling[];
presets: readonly Preset[];
Expand All @@ -53,6 +54,7 @@ const PRESET_LABELS: Record<Preset, string> = {
'dash-video': 'DASH Video',
audio: 'Audio',
'background-video': 'Background Video',
'vimeo-video': 'Vimeo Video',
};

export function Navbar({
Expand All @@ -79,6 +81,7 @@ export function Navbar({
isSimpleHls,
isMuxVideo,
isMuxAudio,
isVimeoVideo,
platforms,
stylings,
presets,
Expand Down Expand Up @@ -107,7 +110,7 @@ export function Navbar({
options={stylings.map((s) => ({
value: s,
label: s === 'css' ? 'CSS' : 'Tailwind',
disabled: s === 'tailwind' && (isBackgroundVideo || platform === 'cdn'),
disabled: s === 'tailwind' && (isBackgroundVideo || isVimeoVideo || platform === 'cdn'),
}))}
/>

Expand Down Expand Up @@ -137,7 +140,7 @@ export function Navbar({
return true;
})
.map((id) => ({ value: id, label: sources[id].label }))}
disabled={isBackgroundVideo}
disabled={isBackgroundVideo || isVimeoVideo}
/>
</div>

Expand Down
14 changes: 14 additions & 0 deletions apps/sandbox/templates/html-vimeo-video/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sandbox — HTML Vimeo Video</title>
<link rel="preconnect" href="https://rsms.me/" />
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
</head>
<body class="font-sans p-2">
<div id="root" class="flex justify-center items-center min-h-screen"></div>
<script type="module" src="./main.ts"></script>
</body>
</html>
32 changes: 32 additions & 0 deletions apps/sandbox/templates/html-vimeo-video/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import '@app/styles.css';
import '@videojs/html/video/player';
import '@videojs/html/media/vimeo-video';
import { createHtmlSandboxState, createLatestLoader } from '@app/shared/html/sandbox-state';
import { loadVideoSkinTag } from '@app/shared/html/skins';
import { onSkinChange } from '@app/shared/sandbox-listener';
import { VIMEO_VIDEO_SRC } from '@app/shared/sources';

const html = String.raw;

const state = createHtmlSandboxState();
const loadLatest = createLatestLoader();

async function render() {
const tag = await loadLatest(() => loadVideoSkinTag(state.skin, state.styling));
if (!tag) return;

document.getElementById('root')!.innerHTML = html`
<video-player>
<${tag} class="aspect-video max-w-4xl mx-auto">
<vimeo-video class="block w-full h-full" src="${VIMEO_VIDEO_SRC}" playsinline></vimeo-video>
</${tag}>
</video-player>
`;
}

render();

onSkinChange((skin) => {
state.skin = skin;
render();
});
14 changes: 14 additions & 0 deletions apps/sandbox/templates/react-vimeo-video/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sandbox — React Vimeo Video</title>
<link rel="preconnect" href="https://rsms.me/" />
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
</head>
<body class="font-sans p-2">
<div id="root" class="flex justify-center items-center min-h-screen"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions apps/sandbox/templates/react-vimeo-video/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import '@app/styles.css';
import { VideoProvider } from '@app/shared/react/providers';
import { VideoSkinComponent } from '@app/shared/react/skins';
import { useSkin } from '@app/shared/react/use-skin';
import { VIMEO_VIDEO_SRC } from '@app/shared/sources';
import type { Styling } from '@app/types';
import { VimeoVideo } from '@videojs/react/media/vimeo-video';
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 styling = useMemo(readStyling, []);

return (
<VideoProvider>
<VideoSkinComponent skin={skin} styling={styling} className="aspect-video max-w-4xl mx-auto">
<VimeoVideo className="block w-full h-full" src={VIMEO_VIDEO_SRC} playsInline />
</VideoSkinComponent>
</VideoProvider>
);
}

createRoot(document.getElementById('root')!).render(<App />);
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@videojs/spf": "workspace:*",
"@videojs/store": "workspace:*",
"@videojs/utils": "workspace:*",
"@vimeo/player": "^2.30.3",
"dashjs": "^5.0.0",
"hls.js": "^1.6.7",
"mux-embed": "^5.17.10"
Expand Down
Loading
Loading