@goboss/web-video-player-sdk 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.

Potentially problematic release.


This version of @goboss/web-video-player-sdk might be problematic. Click here for more details.

package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GoBOSS
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,331 @@
1
+ # Web Video Player SDK
2
+
3
+ A unified, high-performance OTT web video player SDK for adaptive streaming with support for HLS/DASH, DRM protection, live streaming, and rich interactive features.
4
+
5
+ ## Features
6
+
7
+ - **Adaptive Streaming**: HLS and DASH support with automatic quality switching
8
+ - **DRM Protection**: Token-based authentication and FairPlay/Widevine support
9
+ - **Interactive Controls**: Full-featured UI with quality selection, playback speed, subtitles
10
+ - **Accessibility**: WebVTT subtitles, audio tracks, keyboard navigation
11
+ - **Live Streaming**: Real-time streaming with adaptive bitrate
12
+ - **Casting**: Chromecast and AirPlay support
13
+ - **Analytics**: Built-in analytics event tracking
14
+ - **Performance**: Optimized for fast loading and smooth playback
15
+ - **React Native Ready**: Works with React 18+ and 19
16
+
17
+ ## Installation
18
+
19
+ ### NPM
20
+
21
+ ```bash
22
+ npm install web-video-player-sdk
23
+ ```
24
+
25
+ ### Yarn
26
+
27
+ ```bash
28
+ yarn add web-video-player-sdk
29
+ ```
30
+
31
+ ### PNPM
32
+
33
+ ```bash
34
+ pnpm add web-video-player-sdk
35
+ ```
36
+
37
+ ## Quick Start
38
+
39
+ ### React Component Usage
40
+
41
+ ```jsx
42
+ import React from 'react';
43
+ import { WebVideoPlayer } from 'web-video-player-sdk';
44
+ import 'web-video-player-sdk/css';
45
+
46
+ export default function App() {
47
+ return (
48
+ <WebVideoPlayer
49
+ src="https://example.com/video.m3u8"
50
+ enableControls={true}
51
+ enableChromecast={true}
52
+ enableSubtitles={true}
53
+ enableQuality={true}
54
+ enablePlaybackSpeed={true}
55
+ enablePiP={true}
56
+ enableFullscreen={true}
57
+ watermark="Your Brand"
58
+ themeColor="#6366f1"
59
+ />
60
+ );
61
+ }
62
+ ```
63
+
64
+ ### TypeScript Types
65
+
66
+ ```tsx
67
+ import type { WebVideoPlayerProps } from 'web-video-player-sdk';
68
+
69
+ const playerProps: WebVideoPlayerProps = {
70
+ src: 'https://example.com/video.m3u8',
71
+ subtitles: [
72
+ {
73
+ id: 'en',
74
+ label: 'English',
75
+ lang: 'en',
76
+ src: 'https://example.com/en.vtt',
77
+ kind: 'subtitles',
78
+ isDefault: true
79
+ }
80
+ ],
81
+ chapters: [
82
+ {
83
+ id: '1',
84
+ title: 'Introduction',
85
+ startTime: 0,
86
+ thumbnail: 'https://example.com/thumb-0.jpg'
87
+ }
88
+ ],
89
+ onAnalyticsEvent: (event) => console.log(event)
90
+ };
91
+ ```
92
+
93
+ ## Core Player API
94
+
95
+ ```jsx
96
+ import { VideoPlayerSDK } from 'web-video-player-sdk';
97
+
98
+ const player = new VideoPlayerSDK({
99
+ container: document.getElementById('player'),
100
+ src: 'https://example.com/video.m3u8',
101
+ autoplay: false,
102
+ muted: false
103
+ });
104
+
105
+ // Playback Control
106
+ player.play();
107
+ player.pause();
108
+ player.seek(30); // seek to 30 seconds
109
+ player.setPlaybackRate(1.5);
110
+ player.setVolume(0.8);
111
+ player.setMute(false);
112
+
113
+ // Quality Control
114
+ player.setQuality(1080); // set quality by height
115
+
116
+ // Subtitles
117
+ player.subtitles.setActiveTrack('en');
118
+ player.subtitles.getActiveTrackId();
119
+
120
+ // Casting
121
+ player.casting.requestSession('video.mp4', 0);
122
+ player.casting.stopCasting();
123
+ player.casting.requestAirPlaySession(videoElement);
124
+
125
+ // Events
126
+ player.on('play', () => console.log('Playing'));
127
+ player.on('pause', () => console.log('Paused'));
128
+ player.on('ended', () => console.log('Ended'));
129
+ player.on('qualitychange', (quality) => console.log('Quality:', quality));
130
+ player.on('subtitlesloaded', (tracks) => console.log('Subtitles:', tracks));
131
+ player.on('audiotracksloaded', (tracks) => console.log('Audio:', tracks));
132
+
133
+ // Cleanup
134
+ player.destroy();
135
+ ```
136
+
137
+ ## CDN Usage (UMD)
138
+
139
+ ```html
140
+ <!DOCTYPE html>
141
+ <html>
142
+ <head>
143
+ <script crossorigin src="https://cdn.jsdelivr.net/npm/react@19/umd/react.production.min.js"></script>
144
+ <script crossorigin src="https://cdn.jsdelivr.net/npm/react-dom@19/umd/react-dom.production.min.js"></script>
145
+ <script src="https://cdn.jsdelivr.net/npm/web-video-player-sdk@1.0.0/dist/index.umd.js"></script>
146
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/web-video-player-sdk@1.0.0/dist/index.css">
147
+ </head>
148
+ <body>
149
+ <div id="player" style="width: 100%; height: 600px;"></div>
150
+
151
+ <script>
152
+ const container = document.getElementById('player');
153
+ const player = new WebVideoPlayerSDK.VideoPlayerSDK({
154
+ container,
155
+ src: 'https://example.com/video.m3u8',
156
+ autoplay: true
157
+ });
158
+ </script>
159
+ </body>
160
+ </html>
161
+ ```
162
+
163
+ ## Configuration Props
164
+
165
+ ### WebVideoPlayer Component
166
+
167
+ ```typescript
168
+ interface WebVideoPlayerProps {
169
+ src: string; // Video source URL (HLS/DASH)
170
+ chapters?: Chapter[]; // Chapter markers
171
+ keyMoments?: KeyMoment[]; // Key moment markers
172
+ subtitles?: SubtitleTrack[]; // Subtitle tracks
173
+ watermark?: string; // Watermark text (default: 'GoBOSS')
174
+ themeColor?: string; // Primary theme color (default: '#6366f1')
175
+ drmConfig?: DrmConfig; // DRM configuration
176
+ onAnalyticsEvent?: (event: AnalyticsEvent) => void;
177
+ onKeyMomentsLoaded?: (keyMoments: KeyMoment[]) => void;
178
+
179
+ // Feature Flags
180
+ enableControls?: boolean; // Show control bar (default: true)
181
+ enableChromecast?: boolean; // Enable Chromecast (default: true)
182
+ enableKeyMoments?: boolean; // Show chapter markers (default: true)
183
+ enableSubtitles?: boolean; // Enable subtitles (default: true)
184
+ enableQuality?: boolean; // Enable quality selector (default: true)
185
+ enablePlaybackSpeed?: boolean; // Enable speed control (default: true)
186
+ enablePiP?: boolean; // Enable Picture-in-Picture (default: true)
187
+ enableFullscreen?: boolean; // Enable fullscreen (default: true)
188
+ }
189
+ ```
190
+
191
+ ### VideoPlayerSDK Constructor
192
+
193
+ ```typescript
194
+ interface VideoPlayerSDKConfig {
195
+ container: HTMLElement; // Container element
196
+ src: string; // Video source URL
197
+ autoplay?: boolean; // Auto-play on load
198
+ muted?: boolean; // Start muted
199
+ keyMoments?: KeyMoment[]; // Chapter data
200
+ subtitles?: SubtitleTrack[]; // Subtitle tracks
201
+ drm?: DrmConfig; // DRM settings
202
+ analyticsCallback?: (event: AnalyticsEvent) => void;
203
+ themeColor?: string; // Theme color
204
+ }
205
+ ```
206
+
207
+ ## DRM Configuration
208
+
209
+ ```typescript
210
+ const drmConfig = {
211
+ authToken: 'your-auth-token', // Bearer token for signed URLs
212
+ watermarkText: 'Your Brand', // Dynamic watermark
213
+ allowedDomains: ['yourdomain.com'], // Allowed playback domains
214
+ fairplayLicenseUrl: 'https://...', // FairPlay license URL
215
+ widevineServiceUrl: 'https://...' // Widevine license URL
216
+ };
217
+ ```
218
+
219
+ ## Subtitle Track Format
220
+
221
+ ```typescript
222
+ interface SubtitleTrack {
223
+ id: string;
224
+ label: string;
225
+ lang: string; // ISO 639-1 code (en, fr, es, etc.)
226
+ src: string; // URL to WebVTT or SRT file
227
+ kind?: 'subtitles' | 'captions';
228
+ isDefault?: boolean;
229
+ }
230
+ ```
231
+
232
+ ## Events
233
+
234
+ The SDK emits the following events:
235
+
236
+ ```typescript
237
+ // Playback Events
238
+ 'play' | 'pause' | 'ended' | 'timeupdate'
239
+
240
+ // Streaming Events
241
+ 'buffering' | 'qualitylevels' | 'qualitychange'
242
+
243
+ // Track Events
244
+ 'subtitlesloaded' | 'audiotracksloaded' | 'audiotrackchange'
245
+
246
+ // Content Events
247
+ 'keymomentsloaded' | 'chaptersloaded' | 'pipchange'
248
+
249
+ // Analytics Events
250
+ 'analytics' // custom analytics event
251
+ ```
252
+
253
+ ## Keyboard Shortcuts
254
+
255
+ - **Space / K**: Play / Pause
256
+ - **J**: Rewind 10s
257
+ - **L**: Forward 10s
258
+ - **↑**: Volume Up
259
+ - **↓**: Volume Down
260
+ - **M**: Toggle Mute
261
+ - **F**: Toggle Fullscreen
262
+ - **P**: Toggle Picture-in-Picture
263
+ - **C**: Toggle Subtitles
264
+
265
+ ## Browser Support
266
+
267
+ | Browser | Version | Support |
268
+ |---------|---------|---------|
269
+ | Chrome | 90+ | ✅ Full |
270
+ | Firefox | 88+ | ✅ Full |
271
+ | Safari | 14+ | ✅ Full |
272
+ | Edge | 90+ | ✅ Full |
273
+ | iOS Safari | 14+ | ✅ HLS only |
274
+ | Android Chrome | 90+ | ✅ Full |
275
+
276
+ ## Performance
277
+
278
+ - Lazy loading with Intersection Observer
279
+ - Optimized HLS.js and DASH.js bundling
280
+ - CSS-in-JS with runtime theming
281
+ - Efficient re-renders with React hooks
282
+ - Adaptive thumbnail generation
283
+
284
+ ## Troubleshooting
285
+
286
+ ### Video not loading
287
+ - Check CORS headers on your video server
288
+ - Verify HTTPS for HLS streams
289
+ - Ensure `crossOrigin="anonymous"` is set
290
+
291
+ ### Subtitles not showing
292
+ - Verify subtitle file format (WebVTT/SRT)
293
+ - Check subtitle language codes (ISO 639-1)
294
+ - Use `enableSubtitles={true}` on component
295
+
296
+ ### Cast not working
297
+ - Ensure Google Cast SDK is loaded: `<script src="https://www.gstatic.com/cv/js/sender/v360_0.js"></script>`
298
+ - Test on a network with mDNS support
299
+ - Check Cast device availability
300
+
301
+ ### Quality switching issues
302
+ - Verify all quality levels have matching codecs
303
+ - Check network connection
304
+ - Monitor browser console for HLS.js errors
305
+
306
+ ## Examples
307
+
308
+ See the `examples/` directory for:
309
+ - React integration
310
+ - TypeScript usage
311
+ - HTML5/vanilla JS
312
+ - Custom UI overlays
313
+ - DRM implementation
314
+
315
+ ## Contributing
316
+
317
+ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
318
+
319
+ ## License
320
+
321
+ MIT - See [LICENSE](LICENSE) file
322
+
323
+ ## Support
324
+
325
+ - 📖 [Documentation](https://github.com/yourusername/web-video-player-sdk)
326
+ - 🐛 [Report Issues](https://github.com/yourusername/web-video-player-sdk/issues)
327
+ - 💬 [Discussions](https://github.com/yourusername/web-video-player-sdk/discussions)
328
+
329
+ ## Changelog
330
+
331
+ See [CHANGELOG.md](CHANGELOG.md) for release notes.