@hanifhan1f/vidstack-react 1.12.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.templates/sandbox/document.css +27 -0
- package/.templates/sandbox/favicon-32x32.png +0 -0
- package/.templates/sandbox/index.html +21 -0
- package/.templates/sandbox/main.tsx +12 -0
- package/.templates/sandbox/player.css +39 -0
- package/.templates/sandbox/player.tsx +121 -0
- package/.templates/sandbox/tracks.ts +23 -0
- package/LICENSE +21 -0
- package/README.md +23 -0
- package/analyze.config.ts +7 -0
- package/build/build-icons.js +62 -0
- package/npm/analyze.json.d.ts +7 -0
- package/package.json +162 -0
- package/rollup.config.ts +256 -0
- package/src/components/announcer.tsx +47 -0
- package/src/components/layouts/default/audio-layout.tsx +231 -0
- package/src/components/layouts/default/context.ts +28 -0
- package/src/components/layouts/default/hooks.ts +13 -0
- package/src/components/layouts/default/icons.tsx +225 -0
- package/src/components/layouts/default/index.ts +11 -0
- package/src/components/layouts/default/media-layout.tsx +259 -0
- package/src/components/layouts/default/slots.tsx +98 -0
- package/src/components/layouts/default/ui/announcer.tsx +22 -0
- package/src/components/layouts/default/ui/buttons.tsx +301 -0
- package/src/components/layouts/default/ui/captions.tsx +16 -0
- package/src/components/layouts/default/ui/controls.tsx +12 -0
- package/src/components/layouts/default/ui/keyboard-display.tsx +132 -0
- package/src/components/layouts/default/ui/menus/accessibility-menu.tsx +100 -0
- package/src/components/layouts/default/ui/menus/audio-menu.tsx +167 -0
- package/src/components/layouts/default/ui/menus/captions-menu.tsx +61 -0
- package/src/components/layouts/default/ui/menus/chapters-menu.tsx +132 -0
- package/src/components/layouts/default/ui/menus/font-menu.tsx +331 -0
- package/src/components/layouts/default/ui/menus/items/menu-checkbox.tsx +72 -0
- package/src/components/layouts/default/ui/menus/items/menu-items.tsx +135 -0
- package/src/components/layouts/default/ui/menus/items/menu-slider.tsx +92 -0
- package/src/components/layouts/default/ui/menus/playback-menu.tsx +232 -0
- package/src/components/layouts/default/ui/menus/settings-menu.tsx +114 -0
- package/src/components/layouts/default/ui/menus/utils.ts +12 -0
- package/src/components/layouts/default/ui/sliders.tsx +136 -0
- package/src/components/layouts/default/ui/time.tsx +73 -0
- package/src/components/layouts/default/ui/title.tsx +24 -0
- package/src/components/layouts/default/ui/tooltip.tsx +27 -0
- package/src/components/layouts/default/ui.ts +8 -0
- package/src/components/layouts/default/video-layout.tsx +344 -0
- package/src/components/layouts/plyr/context.ts +26 -0
- package/src/components/layouts/plyr/icons/plyr-airplay.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-captions-off.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-captions-on.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-download.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-enter-fullscreen.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-exit-fullscreen.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-fast-forward.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-muted.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-pause.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-pip.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-play.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-restart.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-rewind.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-settings.js +1 -0
- package/src/components/layouts/plyr/icons/plyr-volume.js +1 -0
- package/src/components/layouts/plyr/icons.tsx +71 -0
- package/src/components/layouts/plyr/index.ts +11 -0
- package/src/components/layouts/plyr/layout.tsx +1024 -0
- package/src/components/layouts/plyr/props.ts +104 -0
- package/src/components/layouts/plyr/slots.tsx +52 -0
- package/src/components/layouts/remotion-ui.ts +13 -0
- package/src/components/layouts/utils.ts +17 -0
- package/src/components/player-callbacks.ts +67 -0
- package/src/components/player.tsx +67 -0
- package/src/components/primitives/instances.ts +92 -0
- package/src/components/primitives/nodes.tsx +58 -0
- package/src/components/primitives/slot.tsx +132 -0
- package/src/components/provider.tsx +187 -0
- package/src/components/text-track.tsx +106 -0
- package/src/components/ui/buttons/airplay-button.tsx +53 -0
- package/src/components/ui/buttons/caption-button.tsx +55 -0
- package/src/components/ui/buttons/fullscreen-button.tsx +55 -0
- package/src/components/ui/buttons/google-cast-button.tsx +53 -0
- package/src/components/ui/buttons/live-button.tsx +56 -0
- package/src/components/ui/buttons/mute-button.tsx +60 -0
- package/src/components/ui/buttons/pip-button.tsx +54 -0
- package/src/components/ui/buttons/play-button.tsx +53 -0
- package/src/components/ui/buttons/seek-button.tsx +55 -0
- package/src/components/ui/buttons/toggle-button.tsx +51 -0
- package/src/components/ui/caption.tsx +70 -0
- package/src/components/ui/captions.tsx +41 -0
- package/src/components/ui/chapter-title.tsx +40 -0
- package/src/components/ui/controls.tsx +90 -0
- package/src/components/ui/gesture.tsx +43 -0
- package/src/components/ui/menu.tsx +251 -0
- package/src/components/ui/poster.tsx +101 -0
- package/src/components/ui/radio-group.tsx +88 -0
- package/src/components/ui/sliders/audio-gain-slider.tsx +55 -0
- package/src/components/ui/sliders/quality-slider.tsx +54 -0
- package/src/components/ui/sliders/slider-callbacks.ts +14 -0
- package/src/components/ui/sliders/slider-value.tsx +13 -0
- package/src/components/ui/sliders/slider.tsx +254 -0
- package/src/components/ui/sliders/speed-slider.tsx +54 -0
- package/src/components/ui/sliders/time-slider.tsx +379 -0
- package/src/components/ui/sliders/volume-slider.tsx +55 -0
- package/src/components/ui/spinner.tsx +105 -0
- package/src/components/ui/thumbnail.tsx +82 -0
- package/src/components/ui/time.tsx +77 -0
- package/src/components/ui/title.tsx +32 -0
- package/src/components/ui/tooltip.tsx +135 -0
- package/src/globals.d.ts +3 -0
- package/src/hooks/create-text-track.ts +22 -0
- package/src/hooks/options/use-audio-gain-options.ts +75 -0
- package/src/hooks/options/use-audio-options.ts +71 -0
- package/src/hooks/options/use-caption-options.ts +95 -0
- package/src/hooks/options/use-chapter-options.ts +97 -0
- package/src/hooks/options/use-playback-rate-options.ts +75 -0
- package/src/hooks/options/use-video-quality-options.ts +123 -0
- package/src/hooks/use-active-text-cues.ts +28 -0
- package/src/hooks/use-active-text-track.ts +19 -0
- package/src/hooks/use-chapter-title.ts +12 -0
- package/src/hooks/use-dom.ts +121 -0
- package/src/hooks/use-media-context.ts +6 -0
- package/src/hooks/use-media-player.ts +19 -0
- package/src/hooks/use-media-provider.ts +31 -0
- package/src/hooks/use-media-remote.ts +37 -0
- package/src/hooks/use-media-state.ts +58 -0
- package/src/hooks/use-signals.ts +24 -0
- package/src/hooks/use-slider-preview.ts +126 -0
- package/src/hooks/use-slider-state.ts +63 -0
- package/src/hooks/use-state.ts +47 -0
- package/src/hooks/use-text-cues.ts +33 -0
- package/src/hooks/use-thumbnails.ts +69 -0
- package/src/icon.ts +37 -0
- package/src/icons.ts +754 -0
- package/src/index.ts +181 -0
- package/src/providers/remotion/index.ts +10 -0
- package/src/providers/remotion/layout-engine.ts +123 -0
- package/src/providers/remotion/loader.ts +35 -0
- package/src/providers/remotion/playback-engine.ts +142 -0
- package/src/providers/remotion/provider.tsx +514 -0
- package/src/providers/remotion/type-check.ts +13 -0
- package/src/providers/remotion/types.ts +94 -0
- package/src/providers/remotion/ui/context.tsx +120 -0
- package/src/providers/remotion/ui/error-boundary.tsx +57 -0
- package/src/providers/remotion/ui/poster.tsx +33 -0
- package/src/providers/remotion/ui/slider-thumbnail.tsx +41 -0
- package/src/providers/remotion/ui/thumbnail.tsx +166 -0
- package/src/providers/remotion/validate.ts +220 -0
- package/src/source.ts +5 -0
- package/src/utils.ts +27 -0
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +11 -0
- package/types/react/src/components/announcer.d.ts +16 -0
- package/types/react/src/components/layouts/default/audio-layout.d.ts +27 -0
- package/types/react/src/components/layouts/default/context.d.ts +14 -0
- package/types/react/src/components/layouts/default/hooks.d.ts +2 -0
- package/types/react/src/components/layouts/default/icons.d.ts +95 -0
- package/types/react/src/components/layouts/default/index.d.ts +5 -0
- package/types/react/src/components/layouts/default/media-layout.d.ts +133 -0
- package/types/react/src/components/layouts/default/slots.d.ts +22 -0
- package/types/react/src/components/layouts/default/ui/announcer.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/buttons.d.ts +54 -0
- package/types/react/src/components/layouts/default/ui/captions.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/controls.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/keyboard-display.d.ts +8 -0
- package/types/react/src/components/layouts/default/ui/menus/accessibility-menu.d.ts +10 -0
- package/types/react/src/components/layouts/default/ui/menus/audio-menu.d.ts +10 -0
- package/types/react/src/components/layouts/default/ui/menus/captions-menu.d.ts +10 -0
- package/types/react/src/components/layouts/default/ui/menus/chapters-menu.d.ts +7 -0
- package/types/react/src/components/layouts/default/ui/menus/font-menu.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/menus/items/menu-checkbox.d.ts +13 -0
- package/types/react/src/components/layouts/default/ui/menus/items/menu-items.d.ts +49 -0
- package/types/react/src/components/layouts/default/ui/menus/items/menu-slider.d.ts +26 -0
- package/types/react/src/components/layouts/default/ui/menus/playback-menu.d.ts +10 -0
- package/types/react/src/components/layouts/default/ui/menus/settings-menu.d.ts +15 -0
- package/types/react/src/components/layouts/default/ui/menus/utils.d.ts +1 -0
- package/types/react/src/components/layouts/default/ui/sliders.d.ts +24 -0
- package/types/react/src/components/layouts/default/ui/time.d.ts +30 -0
- package/types/react/src/components/layouts/default/ui/title.d.ts +6 -0
- package/types/react/src/components/layouts/default/ui/tooltip.d.ts +12 -0
- package/types/react/src/components/layouts/default/ui.d.ts +8 -0
- package/types/react/src/components/layouts/default/video-layout.d.ts +47 -0
- package/types/react/src/components/layouts/plyr/context.d.ts +12 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-airplay.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-captions-off.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-captions-on.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-download.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-enter-fullscreen.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-exit-fullscreen.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-fast-forward.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-muted.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-pause.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-pip.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-play.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-restart.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-rewind.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-settings.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons/plyr-volume.d.ts +2 -0
- package/types/react/src/components/layouts/plyr/icons.d.ts +25 -0
- package/types/react/src/components/layouts/plyr/index.d.ts +6 -0
- package/types/react/src/components/layouts/plyr/layout.d.ts +17 -0
- package/types/react/src/components/layouts/plyr/props.d.ts +71 -0
- package/types/react/src/components/layouts/plyr/slots.d.ts +9 -0
- package/types/react/src/components/layouts/remotion-ui.d.ts +3 -0
- package/types/react/src/components/layouts/utils.d.ts +1 -0
- package/types/react/src/components/player-callbacks.d.ts +6 -0
- package/types/react/src/components/player.d.ts +32 -0
- package/types/react/src/components/primitives/instances.d.ts +83 -0
- package/types/react/src/components/primitives/nodes.d.ts +15 -0
- package/types/react/src/components/primitives/slot.d.ts +11 -0
- package/types/react/src/components/provider.d.ts +26 -0
- package/types/react/src/components/text-track.d.ts +100 -0
- package/types/react/src/components/ui/buttons/airplay-button.d.ts +22 -0
- package/types/react/src/components/ui/buttons/caption-button.d.ts +24 -0
- package/types/react/src/components/ui/buttons/fullscreen-button.d.ts +24 -0
- package/types/react/src/components/ui/buttons/google-cast-button.d.ts +22 -0
- package/types/react/src/components/ui/buttons/live-button.d.ts +26 -0
- package/types/react/src/components/ui/buttons/mute-button.d.ts +30 -0
- package/types/react/src/components/ui/buttons/pip-button.d.ts +24 -0
- package/types/react/src/components/ui/buttons/play-button.d.ts +23 -0
- package/types/react/src/components/ui/buttons/seek-button.d.ts +25 -0
- package/types/react/src/components/ui/buttons/toggle-button.d.ts +22 -0
- package/types/react/src/components/ui/caption.d.ts +11 -0
- package/types/react/src/components/ui/captions.d.ts +20 -0
- package/types/react/src/components/ui/chapter-title.d.ts +20 -0
- package/types/react/src/components/ui/controls.d.ts +40 -0
- package/types/react/src/components/ui/gesture.d.ts +20 -0
- package/types/react/src/components/ui/menu.d.ts +102 -0
- package/types/react/src/components/ui/poster.d.ts +25 -0
- package/types/react/src/components/ui/radio-group.d.ts +39 -0
- package/types/react/src/components/ui/sliders/audio-gain-slider.d.ts +29 -0
- package/types/react/src/components/ui/sliders/quality-slider.d.ts +28 -0
- package/types/react/src/components/ui/sliders/slider-callbacks.d.ts +6 -0
- package/types/react/src/components/ui/sliders/slider-value.d.ts +9 -0
- package/types/react/src/components/ui/sliders/slider.d.ts +134 -0
- package/types/react/src/components/ui/sliders/speed-slider.d.ts +28 -0
- package/types/react/src/components/ui/sliders/time-slider.d.ts +124 -0
- package/types/react/src/components/ui/sliders/volume-slider.d.ts +29 -0
- package/types/react/src/components/ui/spinner.d.ts +31 -0
- package/types/react/src/components/ui/thumbnail.d.ts +26 -0
- package/types/react/src/components/ui/time.d.ts +20 -0
- package/types/react/src/components/ui/title.d.ts +15 -0
- package/types/react/src/components/ui/tooltip.d.ts +63 -0
- package/types/react/src/hooks/create-text-track.d.ts +7 -0
- package/types/react/src/hooks/options/use-audio-gain-options.d.ts +22 -0
- package/types/react/src/hooks/options/use-audio-options.d.ts +17 -0
- package/types/react/src/hooks/options/use-caption-options.d.ts +24 -0
- package/types/react/src/hooks/options/use-chapter-options.d.ts +18 -0
- package/types/react/src/hooks/options/use-playback-rate-options.d.ts +22 -0
- package/types/react/src/hooks/options/use-video-quality-options.d.ts +35 -0
- package/types/react/src/hooks/use-active-text-cues.d.ts +6 -0
- package/types/react/src/hooks/use-active-text-track.d.ts +5 -0
- package/types/react/src/hooks/use-chapter-title.d.ts +4 -0
- package/types/react/src/hooks/use-dom.d.ts +9 -0
- package/types/react/src/hooks/use-media-context.d.ts +1 -0
- package/types/react/src/hooks/use-media-player.d.ts +7 -0
- package/types/react/src/hooks/use-media-provider.d.ts +7 -0
- package/types/react/src/hooks/use-media-remote.d.ts +12 -0
- package/types/react/src/hooks/use-media-state.d.ts +15 -0
- package/types/react/src/hooks/use-signals.d.ts +5 -0
- package/types/react/src/hooks/use-slider-preview.d.ts +27 -0
- package/types/react/src/hooks/use-slider-state.d.ts +16 -0
- package/types/react/src/hooks/use-state.d.ts +18 -0
- package/types/react/src/hooks/use-text-cues.d.ts +6 -0
- package/types/react/src/hooks/use-thumbnails.d.ts +16 -0
- package/types/react/src/icon.d.ts +17 -0
- package/types/react/src/icons.d.ts +215 -0
- package/types/react/src/index.d.ts +78 -0
- package/types/react/src/providers/remotion/index.d.ts +7 -0
- package/types/react/src/providers/remotion/layout-engine.d.ts +8 -0
- package/types/react/src/providers/remotion/loader.d.ts +9 -0
- package/types/react/src/providers/remotion/playback-engine.d.ts +11 -0
- package/types/react/src/providers/remotion/provider.d.ts +26 -0
- package/types/react/src/providers/remotion/type-check.d.ts +6 -0
- package/types/react/src/providers/remotion/types.d.ts +91 -0
- package/types/react/src/providers/remotion/ui/context.d.ts +17 -0
- package/types/react/src/providers/remotion/ui/error-boundary.d.ts +21 -0
- package/types/react/src/providers/remotion/ui/poster.d.ts +18 -0
- package/types/react/src/providers/remotion/ui/slider-thumbnail.d.ts +17 -0
- package/types/react/src/providers/remotion/ui/thumbnail.d.ts +32 -0
- package/types/react/src/providers/remotion/validate.d.ts +12 -0
- package/types/react/src/source.d.ts +3 -0
- package/types/react/src/utils.d.ts +3 -0
- package/types/vidstack/src/core/api/src-types.d.ts +50 -0
- package/types/vidstack/src/utils/mime.d.ts +15 -0
- package/types/vidstack/src/utils/network.d.ts +17 -0
- package/types/vidstack/src/utils/support.d.ts +72 -0
- package/vite.config.ts +23 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*************************************************************************************************
|
|
2
|
+
* Document
|
|
3
|
+
*************************************************************************************************/
|
|
4
|
+
|
|
5
|
+
* {
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
html,
|
|
10
|
+
body {
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
width: 100vw;
|
|
14
|
+
height: 100vh;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
body {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
main {
|
|
24
|
+
width: 100%;
|
|
25
|
+
max-width: 980px;
|
|
26
|
+
margin-inline: auto;
|
|
27
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Vidstack React Sandbox</title>
|
|
4
|
+
|
|
5
|
+
<meta charset="utf-8" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
|
|
8
|
+
<link rel="icon" type="image/png" sizes="32x32" href="/sandbox/favicon-32x32.png" />
|
|
9
|
+
|
|
10
|
+
<link rel="stylesheet" href="./document.css" />
|
|
11
|
+
<link rel="stylesheet" href="./player.css" />
|
|
12
|
+
|
|
13
|
+
<script src="./main.tsx" type="module"></script>
|
|
14
|
+
</head>
|
|
15
|
+
|
|
16
|
+
<body>
|
|
17
|
+
<main>
|
|
18
|
+
<div id="player"></div>
|
|
19
|
+
</main>
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import ReactDOM from 'react-dom/client';
|
|
4
|
+
|
|
5
|
+
import { Player } from './player';
|
|
6
|
+
|
|
7
|
+
const root = document.getElementById('player')!;
|
|
8
|
+
ReactDOM.createRoot(root).render(
|
|
9
|
+
<React.StrictMode>
|
|
10
|
+
<Player />
|
|
11
|
+
</React.StrictMode>,
|
|
12
|
+
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
@import '../../vidstack/styles/player/base.css';
|
|
2
|
+
@import '../../vidstack/styles/player/default/theme.css';
|
|
3
|
+
@import '../../vidstack/styles/player/default/layouts/audio.css';
|
|
4
|
+
@import '../../vidstack/styles/player/default/layouts/video.css';
|
|
5
|
+
@import '../../vidstack/styles/player/plyr/theme.css';
|
|
6
|
+
|
|
7
|
+
.player {
|
|
8
|
+
--brand-color: #f5f5f5;
|
|
9
|
+
--focus-color: #4e9cf6;
|
|
10
|
+
|
|
11
|
+
--audio-brand: var(--brand-color);
|
|
12
|
+
--audio-focus-ring-color: var(--focus-color);
|
|
13
|
+
--audio-border-radius: 2px;
|
|
14
|
+
|
|
15
|
+
--video-brand: var(--brand-color);
|
|
16
|
+
--video-focus-ring-color: var(--focus-color);
|
|
17
|
+
--video-border-radius: 2px;
|
|
18
|
+
|
|
19
|
+
/* 👉 https://vidstack.io/docs/player/components/layouts/default#css-variables for more. */
|
|
20
|
+
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.player[data-view-type='audio'] .vds-poster {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.player[data-view-type='video'] {
|
|
29
|
+
aspect-ratio: 16 /9;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.src-buttons {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: space-evenly;
|
|
36
|
+
margin-top: 40px;
|
|
37
|
+
margin-inline: auto;
|
|
38
|
+
max-width: 300px;
|
|
39
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
isHLSProvider,
|
|
5
|
+
MediaPlayer,
|
|
6
|
+
MediaProvider,
|
|
7
|
+
Poster,
|
|
8
|
+
Track,
|
|
9
|
+
type MediaCanPlayDetail,
|
|
10
|
+
type MediaCanPlayEvent,
|
|
11
|
+
type MediaPlayerInstance,
|
|
12
|
+
type MediaProviderAdapter,
|
|
13
|
+
type MediaProviderChangeEvent,
|
|
14
|
+
} from '../src';
|
|
15
|
+
import {
|
|
16
|
+
DefaultAudioLayout,
|
|
17
|
+
defaultLayoutIcons,
|
|
18
|
+
DefaultVideoLayout,
|
|
19
|
+
} from '../src/components/layouts/default';
|
|
20
|
+
import { PlyrLayout, plyrLayoutIcons } from '../src/components/layouts/plyr';
|
|
21
|
+
import { textTracks } from './tracks';
|
|
22
|
+
|
|
23
|
+
export function Player() {
|
|
24
|
+
let player = React.useRef<MediaPlayerInstance>(null),
|
|
25
|
+
[src, setSrc] = React.useState('');
|
|
26
|
+
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
// Initialize src.
|
|
29
|
+
changeSource('audio');
|
|
30
|
+
|
|
31
|
+
// Subscribe to state updates.
|
|
32
|
+
return player.current!.subscribe(({ paused, viewType }) => {
|
|
33
|
+
// console.log('is paused?', '->', paused);
|
|
34
|
+
// console.log('is audio view?', '->', viewType === 'audio');
|
|
35
|
+
});
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
function onProviderChange(
|
|
39
|
+
provider: MediaProviderAdapter | null,
|
|
40
|
+
nativeEvent: MediaProviderChangeEvent,
|
|
41
|
+
) {
|
|
42
|
+
// We can configure provider's here.
|
|
43
|
+
if (isHLSProvider(provider)) {
|
|
44
|
+
provider.config = {};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// We can listen for the `can-play` event to be notified when the player is ready.
|
|
49
|
+
function onCanPlay(detail: MediaCanPlayDetail, nativeEvent: MediaCanPlayEvent) {
|
|
50
|
+
// ...
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function changeSource(type: string) {
|
|
54
|
+
switch (type) {
|
|
55
|
+
case 'audio':
|
|
56
|
+
setSrc('https://files.vidstack.io/sprite-fight/audio.mp3');
|
|
57
|
+
break;
|
|
58
|
+
case 'video':
|
|
59
|
+
setSrc('https://files.vidstack.io/sprite-fight/480p.mp4');
|
|
60
|
+
break;
|
|
61
|
+
case 'hls':
|
|
62
|
+
setSrc('https://files.vidstack.io/sprite-fight/hls/stream.m3u8');
|
|
63
|
+
break;
|
|
64
|
+
case 'dash':
|
|
65
|
+
setSrc('https://files.vidstack.io/sprite-fight/dash/stream.mpd');
|
|
66
|
+
break;
|
|
67
|
+
case 'live':
|
|
68
|
+
setSrc('https://stream.mux.com/v69RSHhFelSm4701snP22dYz2jICy4E4FUyk02rW4gxRM.m3u8');
|
|
69
|
+
break;
|
|
70
|
+
case 'youtube':
|
|
71
|
+
setSrc('youtube/_cMxraX_5RE');
|
|
72
|
+
break;
|
|
73
|
+
case 'vimeo':
|
|
74
|
+
setSrc('vimeo/640499893');
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<>
|
|
81
|
+
<MediaPlayer
|
|
82
|
+
className="player"
|
|
83
|
+
title="Sprite Fight"
|
|
84
|
+
src={src}
|
|
85
|
+
crossOrigin
|
|
86
|
+
playsInline
|
|
87
|
+
onProviderChange={onProviderChange}
|
|
88
|
+
onCanPlay={onCanPlay}
|
|
89
|
+
ref={player}
|
|
90
|
+
>
|
|
91
|
+
<MediaProvider>
|
|
92
|
+
<Poster
|
|
93
|
+
className="vds-poster"
|
|
94
|
+
src="https://image.mux.com/VZtzUzGRv02OhRnZCxcNg49OilvolTqdnFLEqBsTwaxU/thumbnail.webp?time=268&width=1200"
|
|
95
|
+
alt="Girl walks into campfire with gnomes surrounding her friend ready for their next meal!"
|
|
96
|
+
/>
|
|
97
|
+
{textTracks.map((track) => (
|
|
98
|
+
<Track {...track} key={track.src} />
|
|
99
|
+
))}
|
|
100
|
+
</MediaProvider>
|
|
101
|
+
|
|
102
|
+
{/* Layouts */}
|
|
103
|
+
<DefaultAudioLayout icons={defaultLayoutIcons} />
|
|
104
|
+
<DefaultVideoLayout
|
|
105
|
+
icons={defaultLayoutIcons}
|
|
106
|
+
thumbnails="https://image.mux.com/VZtzUzGRv02OhRnZCxcNg49OilvolTqdnFLEqBsTwaxU/storyboard.vtt"
|
|
107
|
+
/>
|
|
108
|
+
</MediaPlayer>
|
|
109
|
+
|
|
110
|
+
<div className="src-buttons">
|
|
111
|
+
<button onClick={() => changeSource('audio')}>Audio</button>
|
|
112
|
+
<button onClick={() => changeSource('video')}>Video</button>
|
|
113
|
+
<button onClick={() => changeSource('hls')}>HLS</button>
|
|
114
|
+
<button onClick={() => changeSource('dash')}>DASH</button>
|
|
115
|
+
<button onClick={() => changeSource('live')}>Live</button>
|
|
116
|
+
<button onClick={() => changeSource('youtube')}>YouTube</button>
|
|
117
|
+
<button onClick={() => changeSource('vimeo')}>Vimeo</button>
|
|
118
|
+
</div>
|
|
119
|
+
</>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const textTracks = [
|
|
2
|
+
// Subtitles
|
|
3
|
+
{
|
|
4
|
+
src: 'https://files.vidstack.io/sprite-fight/subs/english.vtt',
|
|
5
|
+
label: 'English',
|
|
6
|
+
language: 'en-US',
|
|
7
|
+
kind: 'subtitles',
|
|
8
|
+
default: true,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
src: 'https://files.vidstack.io/sprite-fight/subs/spanish.vtt',
|
|
12
|
+
label: 'Spanish',
|
|
13
|
+
language: 'es-ES',
|
|
14
|
+
kind: 'subtitles',
|
|
15
|
+
},
|
|
16
|
+
// Chapters
|
|
17
|
+
{
|
|
18
|
+
src: 'https://files.vidstack.io/sprite-fight/chapters.vtt',
|
|
19
|
+
kind: 'chapters',
|
|
20
|
+
language: 'en-US',
|
|
21
|
+
default: true,
|
|
22
|
+
},
|
|
23
|
+
] as const;
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Rahim Alwer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Vidstack React
|
|
2
|
+
|
|
3
|
+
[![package-badge]][package]
|
|
4
|
+
[![discord-badge]][discord]
|
|
5
|
+
|
|
6
|
+
Vidstack is a video/audio platform for frontend developers to build high-quality and accessible
|
|
7
|
+
experiences on the web.
|
|
8
|
+
|
|
9
|
+
## 📖 Docs
|
|
10
|
+
|
|
11
|
+
You can find our documentation at [vidstack.io](https://www.vidstack.io).
|
|
12
|
+
|
|
13
|
+
## 📝 License
|
|
14
|
+
|
|
15
|
+
Vidstack React is [MIT licensed](./LICENSE).
|
|
16
|
+
|
|
17
|
+
[vime]: https://github.com/vime-js/vime
|
|
18
|
+
[plyr]: https://github.com/sampotts/plyr
|
|
19
|
+
[package]: https://www.npmjs.com/package/@vidstack/react
|
|
20
|
+
[package-badge]: https://img.shields.io/npm/v/@vidstack/react/next?style=flat-square
|
|
21
|
+
[discord]: https://discord.gg/QAjfh2gZE4
|
|
22
|
+
[discord-badge]: https://img.shields.io/discord/742612686679965696?color=%235865F2&label=%20&logo=discord&logoColor=white&style=flat-square
|
|
23
|
+
[discussions]: https://github.com/vidstack/player/discussions
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { kebabToCamelCase, kebabToPascalCase } from 'maverick.js/std';
|
|
6
|
+
|
|
7
|
+
const DIRNAME = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
const ROOT_DIR = path.resolve(DIRNAME, '..'),
|
|
10
|
+
ICONS_DIR = path.resolve(ROOT_DIR, 'node_modules/media-icons/raw');
|
|
11
|
+
|
|
12
|
+
async function buildIcons() {
|
|
13
|
+
const files = await fs.readdir(ICONS_DIR, 'utf-8'),
|
|
14
|
+
icons = {},
|
|
15
|
+
ignore = new Set(['.DS_Store']);
|
|
16
|
+
|
|
17
|
+
for (const file of files) {
|
|
18
|
+
if (ignore.has(file)) continue;
|
|
19
|
+
const name = path.basename(file, path.extname(file));
|
|
20
|
+
icons[name] = await fs.readFile(path.resolve(ICONS_DIR, file), 'utf-8');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const outFile = path.resolve(ROOT_DIR, 'src/icons.ts');
|
|
24
|
+
|
|
25
|
+
const svgPathImports = Object.keys(icons)
|
|
26
|
+
.map((name) => kebabToCamelCase(name) + 'Paths')
|
|
27
|
+
.join(',\n');
|
|
28
|
+
|
|
29
|
+
const alias = {
|
|
30
|
+
airplay: 'AirPlay',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const components = Object.keys(icons)
|
|
34
|
+
.map((iconName) => {
|
|
35
|
+
const IconName = (alias[iconName] ?? kebabToPascalCase(iconName)) + 'Icon';
|
|
36
|
+
return (
|
|
37
|
+
`/** [Click here to preview icon](https://vidstack.io/media-icons?lib=react&icon=${iconName}) */\n` +
|
|
38
|
+
`export const ${IconName}: IconComponent = /* #__PURE__*/ forwardRef` +
|
|
39
|
+
'((props, ref) => {\n' +
|
|
40
|
+
` return createElement(Icon, { ...props, className: cn(props.className), ref, paths: ${
|
|
41
|
+
kebabToCamelCase(iconName) + 'Paths'
|
|
42
|
+
} });\n` +
|
|
43
|
+
'});\n' +
|
|
44
|
+
`${IconName}.displayName = 'Vidstack${IconName}';`
|
|
45
|
+
);
|
|
46
|
+
})
|
|
47
|
+
.join('\n\n');
|
|
48
|
+
|
|
49
|
+
await fs.writeFile(
|
|
50
|
+
outFile,
|
|
51
|
+
`import { ${svgPathImports} } from 'media-icons';
|
|
52
|
+
import { createElement, forwardRef } from 'react';
|
|
53
|
+
|
|
54
|
+
import { Icon, type IconComponent } from './icon';
|
|
55
|
+
|
|
56
|
+
const cn = (className?: string) => className ? \`\${className} vds-icon\` : 'vds-icon';
|
|
57
|
+
|
|
58
|
+
${components}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
await buildIcons();
|
package/package.json
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hanifhan1f/vidstack-react",
|
|
3
|
+
"version": "1.12.13",
|
|
4
|
+
"description": "UI component library for building high-quality, accessible video and audio experiences on the web.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"sideEffects": ["*.css"],
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=18"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"analyze": "maverick analyze \"src/**/*.tsx\" --framework react --project tsconfig.build.json",
|
|
14
|
+
"dev": "pnpm clean && pnpm build:icons && pnpm declarations && pnpm watch",
|
|
15
|
+
"bundle": "rollup --config rollup.config.ts --configPlugin ../vidstack/build/rollup-ts.js",
|
|
16
|
+
"build": "pnpm build:icons && pnpm bundle",
|
|
17
|
+
"build:icons": "node build/build-icons.js",
|
|
18
|
+
"build:types": "pnpm run bundle --config-types",
|
|
19
|
+
"declarations": "tsc -p tsconfig.build.json",
|
|
20
|
+
"sandbox": "node ../../.scripts/sandbox.js",
|
|
21
|
+
"sandbox:build": "vite build sandbox",
|
|
22
|
+
"types": "pnpm build:icons && pnpm declarations && pnpm build:types",
|
|
23
|
+
"clean": "rimraf dist-npm",
|
|
24
|
+
"format": "prettier src --write --loglevel warn",
|
|
25
|
+
"link:styles": "ln -s ../vidstack/styles ./styles",
|
|
26
|
+
"watch": "pnpm watch:types & pnpm run bundle -w",
|
|
27
|
+
"watch:types": "pnpm run declarations -w & pnpm run build:types -w"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@types/react": "^18.0.0 || ^19.0.0",
|
|
31
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@floating-ui/dom": "^1.6.10",
|
|
35
|
+
"media-captions": "^1.0.4"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@maverick-js/cli": "0.43.2",
|
|
39
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
40
|
+
"@types/fs-extra": "^11.0.4",
|
|
41
|
+
"@types/react": "^19.0.0",
|
|
42
|
+
"@types/react-dom": "^19.0.0",
|
|
43
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
44
|
+
"esbuild": "^0.23.0",
|
|
45
|
+
"fs-extra": "^11.2.0",
|
|
46
|
+
"get-tsconfig": "^4.7.6",
|
|
47
|
+
"magic-string": "^0.30.11",
|
|
48
|
+
"maverick.js": "0.43.2",
|
|
49
|
+
"media-icons": "^1.1.5",
|
|
50
|
+
"react": "^19.0.0",
|
|
51
|
+
"react-dom": "^19.0.0",
|
|
52
|
+
"remotion": "4.0.193",
|
|
53
|
+
"rimraf": "^3.0.2",
|
|
54
|
+
"rollup": "^4.20.0",
|
|
55
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
56
|
+
"tslib": "^2.6.3",
|
|
57
|
+
"tsx": "^4.16.5",
|
|
58
|
+
"type-fest": "^3.13.1",
|
|
59
|
+
"typescript": "^5.6.0",
|
|
60
|
+
"@hanifhan1f/vidstack": "workspace:*",
|
|
61
|
+
"vite": "^5.3.5"
|
|
62
|
+
},
|
|
63
|
+
"contributors": [
|
|
64
|
+
"Rahim Alwer <rahim.alwer@gmail.com>"
|
|
65
|
+
],
|
|
66
|
+
"repository": {
|
|
67
|
+
"type": "git",
|
|
68
|
+
"url": "https://github.com/vidstack/player.git",
|
|
69
|
+
"directory": "packages/react"
|
|
70
|
+
},
|
|
71
|
+
"bugs": {
|
|
72
|
+
"url": "https://github.com/vidstack/player/issues"
|
|
73
|
+
},
|
|
74
|
+
"exports": {
|
|
75
|
+
".": "./src/index.ts",
|
|
76
|
+
"./icons": "./src/icons.ts",
|
|
77
|
+
"./player/remotion": "./src/providers/remotion/index.ts",
|
|
78
|
+
"./player/layouts/default": "./src/components/layouts/default/index.ts",
|
|
79
|
+
"./player/layouts/plyr": "./src/components/layouts/plyr/index.ts",
|
|
80
|
+
"./player/styles/*": "./styles/player/*",
|
|
81
|
+
"./package.json": "./package.json"
|
|
82
|
+
},
|
|
83
|
+
"$types": "index.d.ts",
|
|
84
|
+
"$exports": {
|
|
85
|
+
".": {
|
|
86
|
+
"types": "./index.d.ts",
|
|
87
|
+
"worker": "./server/vidstack.js",
|
|
88
|
+
"development": "./dev/vidstack.js",
|
|
89
|
+
"default": "./prod/vidstack.js"
|
|
90
|
+
},
|
|
91
|
+
"./icons": {
|
|
92
|
+
"types": "./icons.d.ts",
|
|
93
|
+
"default": "./prod/vidstack-icons.js"
|
|
94
|
+
},
|
|
95
|
+
"./player/remotion": {
|
|
96
|
+
"types": "./player/remotion.d.ts",
|
|
97
|
+
"worker": "./server/vidstack-remotion.js",
|
|
98
|
+
"development": "./dev/player/vidstack-remotion.js",
|
|
99
|
+
"default": "./prod/player/vidstack-remotion.js"
|
|
100
|
+
},
|
|
101
|
+
"./player/layouts/default": {
|
|
102
|
+
"types": "./player/layouts/default.d.ts",
|
|
103
|
+
"worker": "./server/vidstack-default-layout.js",
|
|
104
|
+
"development": "./dev/player/vidstack-default-layout.js",
|
|
105
|
+
"default": "./prod/player/vidstack-default-layout.js"
|
|
106
|
+
},
|
|
107
|
+
"./player/layouts/plyr": {
|
|
108
|
+
"types": "./player/layouts/plyr.d.ts",
|
|
109
|
+
"worker": "./server/vidstack-plyr-layout.js",
|
|
110
|
+
"development": "./dev/player/vidstack-plyr-layout.js",
|
|
111
|
+
"default": "./prod/player/vidstack-plyr-layout.js"
|
|
112
|
+
},
|
|
113
|
+
"./player/styles/*": "./player/styles/*",
|
|
114
|
+
"./types/*": "./types/*",
|
|
115
|
+
"./dom.d.ts": "./dom.d.ts",
|
|
116
|
+
"./google-cast.d.ts": "./google-cast.d.ts",
|
|
117
|
+
"./package.json": "./package.json",
|
|
118
|
+
"./tailwind.cjs": {
|
|
119
|
+
"types": "./tailwind.d.cts",
|
|
120
|
+
"default": "./tailwind.cjs"
|
|
121
|
+
},
|
|
122
|
+
"./analyze.json": {
|
|
123
|
+
"types": "./analyze.json.d.ts",
|
|
124
|
+
"default": "./analyze.json"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"publishConfig": {
|
|
128
|
+
"access": "public"
|
|
129
|
+
},
|
|
130
|
+
"keywords": [
|
|
131
|
+
"accessible",
|
|
132
|
+
"analytics",
|
|
133
|
+
"audio",
|
|
134
|
+
"customizable",
|
|
135
|
+
"dailymotion",
|
|
136
|
+
"elements",
|
|
137
|
+
"extensible",
|
|
138
|
+
"file",
|
|
139
|
+
"framework-agnostic",
|
|
140
|
+
"headless",
|
|
141
|
+
"hls",
|
|
142
|
+
"html5",
|
|
143
|
+
"jwplayer",
|
|
144
|
+
"media",
|
|
145
|
+
"plyr",
|
|
146
|
+
"player",
|
|
147
|
+
"react",
|
|
148
|
+
"spec-compliant",
|
|
149
|
+
"universal",
|
|
150
|
+
"uploader",
|
|
151
|
+
"vds",
|
|
152
|
+
"video",
|
|
153
|
+
"videojs",
|
|
154
|
+
"vidstack",
|
|
155
|
+
"vime",
|
|
156
|
+
"vimeo",
|
|
157
|
+
"web-component",
|
|
158
|
+
"tailwind",
|
|
159
|
+
"universal",
|
|
160
|
+
"youtube"
|
|
161
|
+
]
|
|
162
|
+
}
|