@clipmux/player 0.1.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/README.md +178 -0
- package/dist/index.cjs +21195 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +62 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +21173 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# @clipmux/player
|
|
2
|
+
|
|
3
|
+
A drop-in React video player with built-in analytics, theming, and HLS support. Powered by [Vidstack](https://vidstack.io) — batteries included.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install @clipmux/player
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { ClipMuxPlayer } from '@clipmux/player'
|
|
13
|
+
|
|
14
|
+
function App() {
|
|
15
|
+
return <ClipMuxPlayer playbackId="your-video-id" />
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
That's it. No CSS imports, no extra dependencies — it just works.
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Basic Playback
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
<ClipMuxPlayer playbackId="abc-123" />
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The player resolves the video URL automatically from the `playbackId`.
|
|
30
|
+
|
|
31
|
+
### Signed / Private Videos
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
<ClipMuxPlayer
|
|
35
|
+
playbackId="abc-123"
|
|
36
|
+
token="eyJhbGciOiJIUzI1NiIs..."
|
|
37
|
+
/>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The `token` is appended to the playback URL as a query parameter for secure delivery.
|
|
41
|
+
|
|
42
|
+
### Custom Source (Escape Hatch)
|
|
43
|
+
|
|
44
|
+
If you use your own CDN or proxy, pass `src` directly. Keep `playbackId` so analytics still tracks correctly:
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<ClipMuxPlayer
|
|
48
|
+
playbackId="abc-123"
|
|
49
|
+
src="https://my-cdn.example.com/videos/abc-123/playlist.m3u8"
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Full Example
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<ClipMuxPlayer
|
|
57
|
+
playbackId="abc-123"
|
|
58
|
+
envKey="pk_live_xxxxxxxx"
|
|
59
|
+
token="eyJ..."
|
|
60
|
+
title="Product Demo"
|
|
61
|
+
poster="https://cdn.example.com/thumb.jpg"
|
|
62
|
+
subtitles="https://cdn.example.com/subs-en.vtt"
|
|
63
|
+
chapters={[
|
|
64
|
+
{ startTime: 0, endTime: 30, title: 'Intro' },
|
|
65
|
+
{ startTime: 30, endTime: 120, title: 'Features' },
|
|
66
|
+
{ startTime: 120, endTime: 180, title: 'Pricing' },
|
|
67
|
+
]}
|
|
68
|
+
autoPlay
|
|
69
|
+
muted
|
|
70
|
+
theme={{ primaryColor: '#6366f1' }}
|
|
71
|
+
onReady={() => console.log('Player loaded')}
|
|
72
|
+
onEnded={() => console.log('Finished')}
|
|
73
|
+
onError={(err) => console.error('Playback error:', err)}
|
|
74
|
+
/>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Props
|
|
78
|
+
|
|
79
|
+
| Prop | Type | Default | Description |
|
|
80
|
+
|------|------|---------|-------------|
|
|
81
|
+
| `playbackId` | `string` | — | ClipMux video ID. Resolves to the HLS URL automatically. |
|
|
82
|
+
| `src` | `string` | — | Direct HLS/DASH URL. Overrides `playbackId` for playback. |
|
|
83
|
+
| `envKey` | `string` | — | Tenant/environment key for multi-tenant analytics. |
|
|
84
|
+
| `token` | `string` | — | Signed playback token for private content. |
|
|
85
|
+
| `title` | `string` | — | Video title displayed in the player UI. |
|
|
86
|
+
| `poster` | `string` | — | Poster/thumbnail image URL. |
|
|
87
|
+
| `subtitles` | `string` | — | VTT subtitle file URL. |
|
|
88
|
+
| `chapters` | `Chapter[]` | — | Chapter markers (converted to VTT internally). |
|
|
89
|
+
| `autoPlay` | `boolean` | `false` | Auto-play on load. |
|
|
90
|
+
| `muted` | `boolean` | `false` | Start muted. |
|
|
91
|
+
| `theme` | `object` | — | `{ primaryColor?, accentColor? }` — customize player colors. |
|
|
92
|
+
| `className` | `string` | — | Additional CSS class on the player container. |
|
|
93
|
+
| `style` | `CSSProperties` | — | Inline styles on the player container. |
|
|
94
|
+
| `analyticsEndpoint` | `string \| false` | Production URL | Override the analytics beacon URL. Set to `false` to disable. |
|
|
95
|
+
| `onReady` | `() => void` | — | Fired when the player is ready to play. |
|
|
96
|
+
| `onError` | `(err: Error) => void` | — | Fired on playback error. |
|
|
97
|
+
| `onEnded` | `() => void` | — | Fired when the video finishes. |
|
|
98
|
+
|
|
99
|
+
## Analytics
|
|
100
|
+
|
|
101
|
+
The player sends playback analytics automatically:
|
|
102
|
+
|
|
103
|
+
- **Events tracked**: `play`, `pause`, `seeking`, `seeked`, `ended`, `error`
|
|
104
|
+
- **Heartbeat**: Every 10 seconds with accumulated `watchedDelta`
|
|
105
|
+
- **Reliability**: Uses `navigator.sendBeacon` on page unload to guarantee delivery
|
|
106
|
+
- **Session tracking**: A unique `sessionId` (UUID) is generated per player mount
|
|
107
|
+
|
|
108
|
+
### Disable Analytics
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<ClipMuxPlayer playbackId="abc-123" analyticsEndpoint={false} />
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Custom Analytics Endpoint
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
<ClipMuxPlayer
|
|
118
|
+
playbackId="abc-123"
|
|
119
|
+
analyticsEndpoint="https://your-proxy.example.com/v1/beacon"
|
|
120
|
+
/>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The endpoint receives `POST` requests with a JSON array of events:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
[
|
|
127
|
+
{
|
|
128
|
+
"event": "heartbeat",
|
|
129
|
+
"ts": "2026-02-16T10:30:00.000Z",
|
|
130
|
+
"videoId": "abc-123",
|
|
131
|
+
"sessionId": "550e8400-e29b-41d4-a716-446655440000",
|
|
132
|
+
"envKey": "pk_live_xxx",
|
|
133
|
+
"currentTime": 45.2,
|
|
134
|
+
"duration": 180,
|
|
135
|
+
"watchedDelta": 10.1
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Theming
|
|
141
|
+
|
|
142
|
+
Customize the player accent color using the `theme` prop:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
<ClipMuxPlayer
|
|
146
|
+
playbackId="abc-123"
|
|
147
|
+
theme={{
|
|
148
|
+
primaryColor: '#6366f1', // Indigo
|
|
149
|
+
accentColor: '#f59e0b', // Amber
|
|
150
|
+
}}
|
|
151
|
+
/>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
`primaryColor` maps to the Vidstack `--video-brand` CSS variable. You can also override styles via the `.clipmux-player` CSS class.
|
|
155
|
+
|
|
156
|
+
## Chapters
|
|
157
|
+
|
|
158
|
+
Pass chapter markers as an array — they're converted to WebVTT internally:
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
<ClipMuxPlayer
|
|
162
|
+
playbackId="abc-123"
|
|
163
|
+
chapters={[
|
|
164
|
+
{ startTime: 0, endTime: 60, title: 'Introduction' },
|
|
165
|
+
{ startTime: 60, endTime: 300, title: 'Main Content' },
|
|
166
|
+
{ startTime: 300, endTime: 360, title: 'Conclusion' },
|
|
167
|
+
]}
|
|
168
|
+
/>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Requirements
|
|
172
|
+
|
|
173
|
+
- **React** ≥ 18
|
|
174
|
+
- No other peer dependencies — Vidstack is bundled inside the package.
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT
|