@structyl/video-player 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 your-lib contributors
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,126 @@
1
+ # @structyl/video-player
2
+
3
+ A full-featured, accessible React video player with HLS streaming, subtitles, playlists, and chapters.
4
+
5
+ ![npm](https://img.shields.io/npm/v/@structyl/video-player)
6
+ ![license](https://img.shields.io/npm/l/@structyl/video-player)
7
+
8
+ `@structyl/video-player` is a single-component, drop-in React video player built on the native `<video>` element and [hls.js](https://github.com/video-dev/hls.js). It adds adaptive HLS streaming, SRT/VTT subtitles, playlists, chapter markers, live video filters, picture-in-picture, and complete keyboard control — styled with the structyl Tailwind theme tokens. It is intended for product teams who need a capable, themable player without wiring up the media stack by hand.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ pnpm add @structyl/video-player
14
+ ```
15
+
16
+ ```bash
17
+ npm install @structyl/video-player
18
+ ```
19
+
20
+ ```bash
21
+ yarn add @structyl/video-player
22
+ ```
23
+
24
+ > `react`, `react-dom`, and `tailwindcss` are peer dependencies. The player renders with structyl theme tokens (`bg`, `fg`, `primary`), so use it within an app configured with `@structyl/styled` / a structyl theme.
25
+
26
+ ## Usage
27
+
28
+ ```tsx
29
+ import { VideoPlayer } from '@structyl/video-player';
30
+ import type { SubtitleTrack, Chapter, PlaylistItem } from '@structyl/video-player';
31
+
32
+ const subtitles: SubtitleTrack[] = [
33
+ { label: 'English', language: 'en', src: '/subs/en.vtt' },
34
+ { label: 'Español', language: 'es', src: '/subs/es.srt' },
35
+ ];
36
+
37
+ const chapters: Chapter[] = [
38
+ { id: '1', title: 'Intro', startTime: 0, endTime: 30 },
39
+ { id: '2', title: 'Demo', startTime: 30, endTime: 120 },
40
+ ];
41
+
42
+ const playlist: PlaylistItem[] = [
43
+ { id: '1', title: 'Episode 1', src: '/videos/ep1.m3u8', poster: '/posters/ep1.jpg' },
44
+ { id: '2', title: 'Episode 2', src: '/videos/ep2.mp4', poster: '/posters/ep2.jpg' },
45
+ ];
46
+
47
+ export function Player() {
48
+ return (
49
+ <VideoPlayer
50
+ src="/videos/stream.m3u8"
51
+ poster="/posters/stream.jpg"
52
+ subtitles={subtitles}
53
+ chapters={chapters}
54
+ playlist={playlist}
55
+ onTimeUpdate={(time) => console.log('current time', time)}
56
+ onEnded={() => console.log('playback finished')}
57
+ />
58
+ );
59
+ }
60
+ ```
61
+
62
+ Plain MP4/WebM works with just a `src`:
63
+
64
+ ```tsx
65
+ <VideoPlayer src="/videos/clip.mp4" />
66
+ ```
67
+
68
+ YouTube URLs are detected automatically and rendered through an embedded player.
69
+
70
+ ## Features
71
+
72
+ - **Adaptive HLS streaming** — `.m3u8` sources play through hls.js, with native HLS fallback on Safari.
73
+ - **Quality selection** — HLS renditions are surfaced as selectable quality levels.
74
+ - **Subtitles & captions** — load SRT and VTT tracks, switch languages, upload local files, and customize font, color, background opacity, and position.
75
+ - **Playlists** — multi-item playback with next/previous, shuffle, and `none` / `one` / `all` repeat modes.
76
+ - **Chapters** — chapter markers rendered on the timeline with title lookup.
77
+ - **Live video filters** — adjust brightness, contrast, saturation, hue, blur, and grayscale in real time.
78
+ - **Picture-in-picture & fullscreen** — toggle both from the controls or keyboard.
79
+ - **Thumbnail scrubbing** — hover the timeline to preview frames.
80
+ - **Full keyboard control** — space/`k` play, arrows seek and adjust volume, `m` mute, `f` fullscreen, `p` PiP, `c` captions, `,`/`.` frame step.
81
+ - **Playback callbacks** — `onPlay`, `onPause`, `onEnded`, `onTimeUpdate`, and `onVolumeChange`.
82
+ - **Auto-hiding controls** and structyl-themed styling out of the box.
83
+
84
+ ## API
85
+
86
+ ### `VideoPlayer`
87
+
88
+ The single exported component. Props:
89
+
90
+ | Prop | Type | Default | Description |
91
+ | --- | --- | --- | --- |
92
+ | `src` | `string` | — | Video source URL. Supports MP4/WebM, HLS (`.m3u8`), and YouTube links. **Required.** |
93
+ | `poster` | `string` | — | Poster image shown before playback. |
94
+ | `autoPlay` | `boolean` | `false` | Start playback automatically. |
95
+ | `loop` | `boolean` | `false` | Loop the current video. |
96
+ | `muted` | `boolean` | `false` | Start muted. |
97
+ | `className` | `string` | `''` | Extra classes merged onto the player container. |
98
+ | `subtitles` | `SubtitleTrack[]` | `[]` | Subtitle/caption tracks to load. |
99
+ | `playlist` | `PlaylistItem[]` | `[]` | Items for multi-video playback. |
100
+ | `chapters` | `Chapter[]` | `[]` | Chapter markers for the timeline. |
101
+ | `onPlay` | `() => void` | — | Fired when playback starts. |
102
+ | `onPause` | `() => void` | — | Fired when playback pauses. |
103
+ | `onEnded` | `() => void` | — | Fired when the current video ends. |
104
+ | `onTimeUpdate` | `(currentTime: number) => void` | — | Fired as the playback position changes. |
105
+ | `onVolumeChange` | `(volume: number) => void` | — | Fired when the volume changes. |
106
+
107
+ ### Exported types
108
+
109
+ | Type | Shape |
110
+ | --- | --- |
111
+ | `VideoPlayerProps` | Props for `<VideoPlayer />` (above). |
112
+ | `SubtitleTrack` | `{ label, language, src, kind? }` |
113
+ | `SubtitleCue` | `{ start, end, text }` |
114
+ | `SubtitleStyle` | `{ fontSize, fontFamily, textColor, backgroundColor, backgroundOpacity, position }` |
115
+ | `PlaylistItem` | `{ id, title, src, poster?, duration? }` |
116
+ | `Chapter` | `{ id, title, startTime, endTime }` |
117
+ | `QualityLevel` | `{ height, width, bitrate, label }` |
118
+ | `VideoFilters` | `{ brightness, contrast, saturation, hue, blur, grayscale }` |
119
+
120
+ ## Part of structyl
121
+
122
+ This package is part of [structyl](https://github.com/imirfanul/structyl) — the React UI library with structure. Full documentation lives at [structyl.dev](https://structyl.dev).
123
+
124
+ ## License
125
+
126
+ MIT