stormcloud-video-player 0.1.12 β 0.2.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 +418 -48
- package/dist/stormcloud-vp.min.js +1 -19
- package/lib/index.cjs +958 -54
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +3591 -2
- package/lib/index.d.ts +3591 -2
- package/lib/index.js +932 -44
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +1669 -0
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -0
- package/lib/player/StormcloudVideoPlayer.d.cts +74 -0
- package/lib/players/FilePlayer.cjs +233 -0
- package/lib/players/FilePlayer.cjs.map +1 -0
- package/lib/players/FilePlayer.d.cts +48 -0
- package/lib/players/HlsPlayer.cjs +1847 -0
- package/lib/players/HlsPlayer.cjs.map +1 -0
- package/lib/players/HlsPlayer.d.cts +37 -0
- package/lib/players/index.cjs +2055 -0
- package/lib/players/index.cjs.map +1 -0
- package/lib/players/index.d.cts +10 -0
- package/lib/sdk/ima.cjs +420 -0
- package/lib/sdk/ima.cjs.map +1 -0
- package/lib/sdk/ima.d.cts +10 -0
- package/lib/types-GpA_hKek.d.cts +67 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +2905 -0
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -0
- package/lib/ui/StormcloudVideoPlayer.d.cts +13 -0
- package/lib/utils/tracking.cjs +250 -0
- package/lib/utils/tracking.cjs.map +1 -0
- package/lib/utils/tracking.d.cts +8 -0
- package/package.json +13 -5
- package/rollup.config.js +62 -0
package/README.md
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
# Stormcloud Video Player
|
|
2
2
|
|
|
3
|
-
A professional
|
|
3
|
+
A professional video player with advanced ad integration for web applications. Built with precision ad break alignment, SCTE-35 signal parsing, and Google IMA SDK integration for seamless VAST/VPAID ad playback. Now featuring a modern, extensible architecture inspired by react-player.
|
|
4
4
|
|
|
5
5
|
## π― Key Features
|
|
6
6
|
|
|
7
|
+
- **Multi-Format Support**: Automatic detection and playback of HLS streams and regular video files
|
|
7
8
|
- **Precision Ad Alignment**: Tight synchronization with SCTE-35 CUE-OUT signals
|
|
8
9
|
- **Smart Mid-Roll Handling**: Automatic detection and playback of remaining ad portions when joining late
|
|
9
10
|
- **Flexible Ad Scheduling**: Support for both SCTE-35 markers and external ad schedules
|
|
10
11
|
- **Enhanced UI Controls**: Beautiful, adaptive video controls that work on any background color
|
|
11
12
|
- **Live Mode Support**: Specialized controls for live streaming with volume adjustment
|
|
12
13
|
- **Cross-Platform**: Works on desktop, mobile, tablets, and smart TVs
|
|
13
|
-
- **React Ready**:
|
|
14
|
+
- **React Ready**: Multiple React components for different use cases
|
|
14
15
|
- **TypeScript Support**: Full type definitions included
|
|
16
|
+
- **Professional Architecture**: Modular player system with lazy loading
|
|
15
17
|
|
|
16
18
|
## π Quick Start
|
|
17
19
|
|
|
@@ -23,6 +25,8 @@ npm install stormcloud-video-player hls.js
|
|
|
23
25
|
|
|
24
26
|
### React Integration
|
|
25
27
|
|
|
28
|
+
#### Option 1: Legacy Component (Recommended for existing projects)
|
|
29
|
+
|
|
26
30
|
```jsx
|
|
27
31
|
import React from "react";
|
|
28
32
|
import { StormcloudVideoPlayerComponent } from "stormcloud-video-player";
|
|
@@ -53,6 +57,47 @@ function MyVideoApp() {
|
|
|
53
57
|
}
|
|
54
58
|
```
|
|
55
59
|
|
|
60
|
+
#### Option 2: New Professional Component (For new projects)
|
|
61
|
+
|
|
62
|
+
```jsx
|
|
63
|
+
import React from "react";
|
|
64
|
+
import StormcloudPlayer from "stormcloud-video-player";
|
|
65
|
+
|
|
66
|
+
function MyVideoApp() {
|
|
67
|
+
return (
|
|
68
|
+
<StormcloudPlayer
|
|
69
|
+
src="https://your-stream.com/playlist.m3u8"
|
|
70
|
+
playing={true}
|
|
71
|
+
muted={true}
|
|
72
|
+
controls={true}
|
|
73
|
+
width="100%"
|
|
74
|
+
height="auto"
|
|
75
|
+
style={{ aspectRatio: "16/9" }}
|
|
76
|
+
// Stormcloud-specific props
|
|
77
|
+
allowNativeHls={true}
|
|
78
|
+
showCustomControls={true}
|
|
79
|
+
licenseKey="your_license_key_here"
|
|
80
|
+
onReady={(player) => {
|
|
81
|
+
console.log("Player is ready!", player);
|
|
82
|
+
}}
|
|
83
|
+
onPlay={() => console.log("Playing")}
|
|
84
|
+
onPause={() => console.log("Paused")}
|
|
85
|
+
onProgress={(state) => console.log("Progress:", state)}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Option 3: Specific Player Types (Optimized bundles)
|
|
92
|
+
|
|
93
|
+
```jsx
|
|
94
|
+
// For HLS streams only (smaller bundle)
|
|
95
|
+
import StormcloudPlayer from "stormcloud-video-player/hls";
|
|
96
|
+
|
|
97
|
+
// For regular video files only (smallest bundle)
|
|
98
|
+
import StormcloudPlayer from "stormcloud-video-player/file";
|
|
99
|
+
```
|
|
100
|
+
|
|
56
101
|
### Vanilla JavaScript
|
|
57
102
|
|
|
58
103
|
```javascript
|
|
@@ -83,7 +128,7 @@ await player.load();
|
|
|
83
128
|
<script src="https://cdn.jsdelivr.net/npm/stormcloud-video-player/dist/stormcloud-vp.min.js"></script>
|
|
84
129
|
|
|
85
130
|
<script>
|
|
86
|
-
const { StormcloudVideoPlayer } = window.
|
|
131
|
+
const { StormcloudVideoPlayer } = window.StormcloudVP;
|
|
87
132
|
|
|
88
133
|
const video = document.getElementById("video");
|
|
89
134
|
const player = new StormcloudVideoPlayer({
|
|
@@ -97,9 +142,169 @@ await player.load();
|
|
|
97
142
|
</script>
|
|
98
143
|
```
|
|
99
144
|
|
|
145
|
+
## ποΈ Professional Architecture
|
|
146
|
+
|
|
147
|
+
The Stormcloud Video Player now follows a professional, modular architecture similar to react-player:
|
|
148
|
+
|
|
149
|
+
### Player System Overview
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
StormcloudPlayer (Main Component)
|
|
153
|
+
βββ Player (Internal Wrapper)
|
|
154
|
+
βββ HlsPlayer (HLS Stream Handler)
|
|
155
|
+
βββ FilePlayer (Regular Video Handler)
|
|
156
|
+
βββ Legacy StormcloudVideoPlayerComponent
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### What Each Player Does
|
|
160
|
+
|
|
161
|
+
#### π¬ **HlsPlayer** - HLS Stream Specialist
|
|
162
|
+
|
|
163
|
+
- **Purpose**: Handles HLS (.m3u8) streams with advanced features
|
|
164
|
+
- **Features**:
|
|
165
|
+
- SCTE-35 ad marker detection and processing
|
|
166
|
+
- Google IMA SDK integration for VAST/VPAID ads
|
|
167
|
+
- Live stream support with low-latency mode
|
|
168
|
+
- Drift correction for live timing
|
|
169
|
+
- Manifest-based and ID3 ad markers
|
|
170
|
+
- Ad failsafe and recovery mechanisms
|
|
171
|
+
|
|
172
|
+
```jsx
|
|
173
|
+
// Automatically used for HLS streams
|
|
174
|
+
<StormcloudPlayer src="https://example.com/stream.m3u8" />
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### πΉ **FilePlayer** - Regular Video Handler
|
|
178
|
+
|
|
179
|
+
- **Purpose**: Handles regular video files (MP4, WebM, etc.)
|
|
180
|
+
- **Features**:
|
|
181
|
+
- Direct video element control
|
|
182
|
+
- Picture-in-Picture support
|
|
183
|
+
- Standard HTML5 video features
|
|
184
|
+
- Lightweight and fast
|
|
185
|
+
- No HLS.js dependency
|
|
186
|
+
|
|
187
|
+
```jsx
|
|
188
|
+
// Automatically used for regular video files
|
|
189
|
+
<StormcloudPlayer src="https://example.com/video.mp4" />
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Automatic Player Selection
|
|
193
|
+
|
|
194
|
+
The system automatically chooses the right player based on your video source:
|
|
195
|
+
|
|
196
|
+
```javascript
|
|
197
|
+
// HLS streams β HlsPlayer
|
|
198
|
+
"https://example.com/playlist.m3u8"; // Uses HlsPlayer
|
|
199
|
+
"https://example.com/stream/index.m3u8"; // Uses HlsPlayer
|
|
200
|
+
|
|
201
|
+
// Regular videos β FilePlayer
|
|
202
|
+
"https://example.com/video.mp4"; // Uses FilePlayer
|
|
203
|
+
"https://example.com/video.webm"; // Uses FilePlayer
|
|
204
|
+
"https://example.com/video.mov"; // Uses FilePlayer
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Bundle Optimization
|
|
208
|
+
|
|
209
|
+
Import only what you need for smaller bundles:
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
// Full player (auto-detection) - ~140KB
|
|
213
|
+
import StormcloudPlayer from "stormcloud-video-player";
|
|
214
|
+
|
|
215
|
+
// HLS only - ~120KB
|
|
216
|
+
import StormcloudPlayer from "stormcloud-video-player/hls";
|
|
217
|
+
|
|
218
|
+
// File only - ~80KB
|
|
219
|
+
import StormcloudPlayer from "stormcloud-video-player/file";
|
|
220
|
+
|
|
221
|
+
// Legacy component - Full features
|
|
222
|
+
import { StormcloudVideoPlayerComponent } from "stormcloud-video-player";
|
|
223
|
+
```
|
|
224
|
+
|
|
100
225
|
## π API Reference
|
|
101
226
|
|
|
102
|
-
###
|
|
227
|
+
### StormcloudPlayer Component (New)
|
|
228
|
+
|
|
229
|
+
#### Props
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
interface StormcloudPlayerProps {
|
|
233
|
+
// Media source
|
|
234
|
+
src?: string;
|
|
235
|
+
|
|
236
|
+
// Playback control
|
|
237
|
+
playing?: boolean;
|
|
238
|
+
loop?: boolean;
|
|
239
|
+
controls?: boolean;
|
|
240
|
+
volume?: number;
|
|
241
|
+
muted?: boolean;
|
|
242
|
+
playbackRate?: number;
|
|
243
|
+
|
|
244
|
+
// Styling
|
|
245
|
+
width?: string | number;
|
|
246
|
+
height?: string | number;
|
|
247
|
+
style?: CSSProperties;
|
|
248
|
+
className?: string;
|
|
249
|
+
wrapperClassName?: string;
|
|
250
|
+
wrapperStyle?: CSSProperties;
|
|
251
|
+
|
|
252
|
+
// Video attributes
|
|
253
|
+
playsInline?: boolean;
|
|
254
|
+
autoplay?: boolean;
|
|
255
|
+
preload?: string;
|
|
256
|
+
poster?: string;
|
|
257
|
+
|
|
258
|
+
// Stormcloud-specific
|
|
259
|
+
allowNativeHls?: boolean;
|
|
260
|
+
lowLatencyMode?: boolean;
|
|
261
|
+
driftToleranceMs?: number;
|
|
262
|
+
immediateManifestAds?: boolean;
|
|
263
|
+
debugAdTiming?: boolean;
|
|
264
|
+
showCustomControls?: boolean;
|
|
265
|
+
licenseKey?: string;
|
|
266
|
+
adFailsafeTimeoutMs?: number;
|
|
267
|
+
|
|
268
|
+
// Event handlers
|
|
269
|
+
onReady?: (player: StormcloudVideoPlayer) => void;
|
|
270
|
+
onStart?: () => void;
|
|
271
|
+
onPlay?: () => void;
|
|
272
|
+
onPause?: () => void;
|
|
273
|
+
onBuffer?: () => void;
|
|
274
|
+
onBufferEnd?: () => void;
|
|
275
|
+
onEnded?: () => void;
|
|
276
|
+
onError?: (
|
|
277
|
+
error: any,
|
|
278
|
+
data?: any,
|
|
279
|
+
hlsInstance?: any,
|
|
280
|
+
hlsGlobal?: any
|
|
281
|
+
) => void;
|
|
282
|
+
onDuration?: (duration: number) => void;
|
|
283
|
+
onSeek?: (seconds: number) => void;
|
|
284
|
+
onProgress?: (state: {
|
|
285
|
+
played: number;
|
|
286
|
+
playedSeconds: number;
|
|
287
|
+
loaded: number;
|
|
288
|
+
loadedSeconds: number;
|
|
289
|
+
}) => void;
|
|
290
|
+
onVolumeToggle?: () => void;
|
|
291
|
+
onFullscreenToggle?: () => void;
|
|
292
|
+
onControlClick?: () => void;
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Methods
|
|
297
|
+
|
|
298
|
+
```typescript
|
|
299
|
+
// Player instance methods (available via ref or onReady)
|
|
300
|
+
player.seekTo(amount: number, type?: 'seconds' | 'fraction')
|
|
301
|
+
player.getCurrentTime(): number | null
|
|
302
|
+
player.getSecondsLoaded(): number | null
|
|
303
|
+
player.getDuration(): number | null
|
|
304
|
+
player.getInternalPlayer(key?: string): any
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### StormcloudVideoPlayer Class (Core)
|
|
103
308
|
|
|
104
309
|
#### Constructor
|
|
105
310
|
|
|
@@ -110,13 +315,19 @@ new StormcloudVideoPlayer(config: StormcloudVideoPlayerConfig)
|
|
|
110
315
|
#### Methods
|
|
111
316
|
|
|
112
317
|
| Method | Description | Returns |
|
|
113
|
-
| ------------------------------------------ | --------------------------------------------- | --------------- |
|
|
318
|
+
| ------------------------------------------ | --------------------------------------------- | --------------- | -------- |
|
|
114
319
|
| `load()` | Initialize and start video playback | `Promise<void>` |
|
|
115
320
|
| `destroy()` | Clean up player resources and event listeners | `void` |
|
|
116
321
|
| `toggleMute()` | Toggle video mute state | `void` |
|
|
117
322
|
| `toggleFullscreen()` | Enter/exit fullscreen mode | `Promise<void>` |
|
|
118
323
|
| `isMuted()` | Check if video is currently muted | `boolean` |
|
|
119
324
|
| `isFullscreen()` | Check if player is in fullscreen mode | `boolean` |
|
|
325
|
+
| `isAdPlaying()` | Check if an ad is currently playing | `boolean` |
|
|
326
|
+
| `isShowingAds()` | Check if ads are being shown | `boolean` |
|
|
327
|
+
| `getCurrentAdIndex()` | Get current ad index in pod | `number` |
|
|
328
|
+
| `getTotalAdsInBreak()` | Get total ads in current break | `number` |
|
|
329
|
+
| `shouldShowNativeControls()` | Check if native controls should be shown | `boolean` |
|
|
330
|
+
| `getStreamType()` | Get detected stream type | `'hls' | 'other'` |
|
|
120
331
|
| `loadDefaultVastFromAdstorm(url, params?)` | Load VAST tags from Adstorm API | `Promise<void>` |
|
|
121
332
|
|
|
122
333
|
#### Configuration Options
|
|
@@ -124,14 +335,14 @@ new StormcloudVideoPlayer(config: StormcloudVideoPlayerConfig)
|
|
|
124
335
|
```typescript
|
|
125
336
|
interface StormcloudVideoPlayerConfig {
|
|
126
337
|
videoElement: HTMLVideoElement; // Target video element
|
|
127
|
-
src: string; // HLS
|
|
338
|
+
src: string; // Stream URL (HLS or regular video)
|
|
128
339
|
autoplay?: boolean; // Auto-start playback (default: false)
|
|
129
340
|
muted?: boolean; // Start muted (default: false)
|
|
130
|
-
allowNativeHls?: boolean; // Use native HLS when available (default:
|
|
341
|
+
allowNativeHls?: boolean; // Use native HLS when available (default: false)
|
|
131
342
|
showCustomControls?: boolean; // Enable enhanced UI controls (default: false)
|
|
132
343
|
lowLatencyMode?: boolean; // Enable low-latency mode for live streams (default: false)
|
|
133
|
-
driftToleranceMs?: number; // Drift tolerance for live streams (default:
|
|
134
|
-
immediateManifestAds?: boolean; // Load ads immediately from manifest (default:
|
|
344
|
+
driftToleranceMs?: number; // Drift tolerance for live streams (default: 1000)
|
|
345
|
+
immediateManifestAds?: boolean; // Load ads immediately from manifest (default: true)
|
|
135
346
|
licenseKey?: string; // API authentication key
|
|
136
347
|
debugAdTiming?: boolean; // Enable debug logging (default: false)
|
|
137
348
|
adFailsafeTimeoutMs?: number; // Ad timeout in milliseconds (default: 10000)
|
|
@@ -157,7 +368,7 @@ The player includes beautiful, adaptive video controls that ensure visibility on
|
|
|
157
368
|
|
|
158
369
|
#### Full Controls (HLS Streams)
|
|
159
370
|
|
|
160
|
-
When `showCustomControls={true}`
|
|
371
|
+
When `showCustomControls={true}` for HLS streams:
|
|
161
372
|
|
|
162
373
|
- Progress timeline with seek functionality
|
|
163
374
|
- Play/pause button with smooth animations
|
|
@@ -166,9 +377,9 @@ When `showCustomControls={true}` and `allowNativeHls={true}` for HLS streams:
|
|
|
166
377
|
- Fullscreen toggle
|
|
167
378
|
- Time display (current/duration)
|
|
168
379
|
|
|
169
|
-
#### Live Mode Controls (Non-HLS or
|
|
380
|
+
#### Live Mode Controls (Non-HLS or when native HLS is used)
|
|
170
381
|
|
|
171
|
-
When `showCustomControls={true}` for
|
|
382
|
+
When `showCustomControls={true}` for regular video files:
|
|
172
383
|
|
|
173
384
|
- Volume control with hover-activated slider
|
|
174
385
|
- Fullscreen toggle
|
|
@@ -184,7 +395,7 @@ All controls use a consistent high-contrast design:
|
|
|
184
395
|
- **Smooth transitions** for professional feel
|
|
185
396
|
|
|
186
397
|
```jsx
|
|
187
|
-
<
|
|
398
|
+
<StormcloudPlayer
|
|
188
399
|
showCustomControls={true}
|
|
189
400
|
wrapperStyle={{ borderRadius: "12px", overflow: "hidden" }}
|
|
190
401
|
onVolumeToggle={() => console.log("Volume toggled")}
|
|
@@ -192,11 +403,11 @@ All controls use a consistent high-contrast design:
|
|
|
192
403
|
/>
|
|
193
404
|
```
|
|
194
405
|
|
|
195
|
-
## π¬ Ad Integration
|
|
406
|
+
## π¬ Ad Integration (HLS Streams Only)
|
|
196
407
|
|
|
197
408
|
### SCTE-35 Support
|
|
198
409
|
|
|
199
|
-
The
|
|
410
|
+
The HlsPlayer automatically detects and responds to SCTE-35 signals embedded in HLS streams:
|
|
200
411
|
|
|
201
412
|
- **CUE-OUT**: Triggers ad break start
|
|
202
413
|
- **CUE-OUT-CONT**: Handles mid-roll continuation
|
|
@@ -218,6 +429,19 @@ When viewers join during an ad break:
|
|
|
218
429
|
- **play_remaining**: Plays the remaining portion of the current ad
|
|
219
430
|
- **skip_to_content**: Skips to main content (configurable via API)
|
|
220
431
|
|
|
432
|
+
### Ad Status Monitoring
|
|
433
|
+
|
|
434
|
+
```jsx
|
|
435
|
+
<StormcloudPlayer
|
|
436
|
+
onReady={(player) => {
|
|
437
|
+
// Monitor ad playback
|
|
438
|
+
console.log("Is ad playing:", player.isAdPlaying());
|
|
439
|
+
console.log("Current ad index:", player.getCurrentAdIndex());
|
|
440
|
+
console.log("Total ads in break:", player.getTotalAdsInBreak());
|
|
441
|
+
}}
|
|
442
|
+
/>
|
|
443
|
+
```
|
|
444
|
+
|
|
221
445
|
## π Authentication
|
|
222
446
|
|
|
223
447
|
The player supports license key authentication for enhanced features:
|
|
@@ -237,36 +461,76 @@ Authenticated requests are sent to:
|
|
|
237
461
|
|
|
238
462
|
## π§ Advanced Configuration
|
|
239
463
|
|
|
240
|
-
### Custom
|
|
464
|
+
### Custom Player Creation
|
|
241
465
|
|
|
242
|
-
|
|
243
|
-
.stormcloud-video-player {
|
|
244
|
-
width: 100%;
|
|
245
|
-
height: 100%;
|
|
246
|
-
background: #000;
|
|
247
|
-
}
|
|
466
|
+
Create your own player with specific capabilities:
|
|
248
467
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
468
|
+
```javascript
|
|
469
|
+
import { createStormcloudPlayer, players } from "stormcloud-video-player";
|
|
470
|
+
|
|
471
|
+
// Create a player with only HLS support
|
|
472
|
+
const HLSOnlyPlayer = createStormcloudPlayer([
|
|
473
|
+
players.find((p) => p.key === "hls"),
|
|
474
|
+
]);
|
|
475
|
+
|
|
476
|
+
// Create a player with custom fallback
|
|
477
|
+
const CustomPlayer = createStormcloudPlayer(
|
|
478
|
+
players,
|
|
479
|
+
players.find((p) => p.key === "file") // fallback to file player
|
|
480
|
+
);
|
|
254
481
|
```
|
|
255
482
|
|
|
256
|
-
###
|
|
483
|
+
### Adding Custom Players
|
|
257
484
|
|
|
258
485
|
```javascript
|
|
259
|
-
|
|
260
|
-
|
|
486
|
+
import StormcloudPlayer from "stormcloud-video-player";
|
|
487
|
+
|
|
488
|
+
// Add a custom player for a specific format
|
|
489
|
+
StormcloudPlayer.addCustomPlayer({
|
|
490
|
+
key: "custom",
|
|
491
|
+
name: "CustomPlayer",
|
|
492
|
+
canPlay: (src) => src.includes("custom://"),
|
|
493
|
+
lazyPlayer: React.lazy(() => import("./CustomPlayer")),
|
|
261
494
|
});
|
|
495
|
+
```
|
|
262
496
|
|
|
263
|
-
|
|
264
|
-
console.log("Ad completed:", event.ad);
|
|
265
|
-
});
|
|
497
|
+
### Player Detection
|
|
266
498
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
499
|
+
```javascript
|
|
500
|
+
import StormcloudPlayer from "stormcloud-video-player";
|
|
501
|
+
|
|
502
|
+
// Check if a URL can be played
|
|
503
|
+
const canPlay = StormcloudPlayer.canPlay("https://example.com/video.m3u8");
|
|
504
|
+
console.log("Can play:", canPlay); // true
|
|
505
|
+
|
|
506
|
+
// Check Picture-in-Picture support
|
|
507
|
+
const canPIP = StormcloudPlayer.canEnablePIP("https://example.com/video.mp4");
|
|
508
|
+
console.log("Supports PIP:", canPIP); // true for file player
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### Event Handling
|
|
512
|
+
|
|
513
|
+
```jsx
|
|
514
|
+
<StormcloudPlayer
|
|
515
|
+
onReady={(player) => {
|
|
516
|
+
console.log("Player ready");
|
|
517
|
+
}}
|
|
518
|
+
onPlay={() => {
|
|
519
|
+
console.log("Playback started");
|
|
520
|
+
}}
|
|
521
|
+
onPause={() => {
|
|
522
|
+
console.log("Playback paused");
|
|
523
|
+
}}
|
|
524
|
+
onProgress={(state) => {
|
|
525
|
+
console.log("Progress:", state.playedSeconds, "of", state.loadedSeconds);
|
|
526
|
+
}}
|
|
527
|
+
onError={(error, data, hlsInstance, hlsGlobal) => {
|
|
528
|
+
console.error("Player error:", error);
|
|
529
|
+
if (hlsInstance) {
|
|
530
|
+
console.log("HLS instance available for recovery");
|
|
531
|
+
}
|
|
532
|
+
}}
|
|
533
|
+
/>
|
|
270
534
|
```
|
|
271
535
|
|
|
272
536
|
## π Browser Support
|
|
@@ -275,41 +539,133 @@ player.on("contentResumed", () => {
|
|
|
275
539
|
- **Mobile**: iOS Safari 12+, Chrome Mobile 60+
|
|
276
540
|
- **Smart TV**: WebOS, Tizen, Android TV, Roku, Apple TV
|
|
277
541
|
|
|
542
|
+
### Format Support by Player
|
|
543
|
+
|
|
544
|
+
#### HlsPlayer
|
|
545
|
+
|
|
546
|
+
- **HLS Streams**: `.m3u8` files
|
|
547
|
+
- **Native HLS**: Safari, iOS Safari (when `allowNativeHls=true`)
|
|
548
|
+
- **HLS.js**: Chrome, Firefox, Edge (automatic fallback)
|
|
549
|
+
|
|
550
|
+
#### FilePlayer
|
|
551
|
+
|
|
552
|
+
- **Video Formats**: MP4, WebM, MOV, AVI, OGV
|
|
553
|
+
- **Audio Formats**: MP3, WAV, OGG, AAC
|
|
554
|
+
- **Streaming**: Progressive download
|
|
555
|
+
- **Picture-in-Picture**: Supported browsers
|
|
556
|
+
|
|
278
557
|
## ποΈ Development
|
|
279
558
|
|
|
280
559
|
### Build Commands
|
|
281
560
|
|
|
282
561
|
```bash
|
|
283
|
-
|
|
284
|
-
npm run
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
npm run
|
|
562
|
+
# Build everything
|
|
563
|
+
npm run build:all
|
|
564
|
+
|
|
565
|
+
# Individual builds
|
|
566
|
+
npm run build:lib # Library build (ESM/CJS)
|
|
567
|
+
npm run build:minified # Minified UMD bundle
|
|
568
|
+
npm run build:dist # Production UMD bundle
|
|
569
|
+
|
|
570
|
+
# Development
|
|
571
|
+
npm run dev # Development watch mode
|
|
572
|
+
npm run clean # Clean build artifacts
|
|
573
|
+
npm run test # Run test suite
|
|
574
|
+
npm run lint # Lint codebase
|
|
288
575
|
```
|
|
289
576
|
|
|
290
577
|
### Project Structure
|
|
291
578
|
|
|
292
579
|
```
|
|
293
580
|
src/
|
|
294
|
-
βββ index.ts
|
|
581
|
+
βββ index.ts # Main exports
|
|
582
|
+
βββ StormcloudPlayer.tsx # New main component
|
|
583
|
+
βββ Player.tsx # Internal wrapper component
|
|
584
|
+
βββ players/
|
|
585
|
+
β βββ index.ts # Player registry
|
|
586
|
+
β βββ HlsPlayer.tsx # HLS stream handler
|
|
587
|
+
β βββ FilePlayer.tsx # Regular video handler
|
|
295
588
|
βββ player/
|
|
296
|
-
β βββ StormcloudVideoPlayer.ts
|
|
589
|
+
β βββ StormcloudVideoPlayer.ts # Core player class
|
|
297
590
|
βββ ui/
|
|
298
|
-
β βββ StormcloudVideoPlayer.tsx
|
|
591
|
+
β βββ StormcloudVideoPlayer.tsx # Legacy React component
|
|
299
592
|
βββ sdk/
|
|
300
|
-
β βββ ima.ts
|
|
593
|
+
β βββ ima.ts # Google IMA integration
|
|
301
594
|
βββ utils/
|
|
302
|
-
β
|
|
303
|
-
βββ
|
|
595
|
+
β βββ tracking.ts # Analytics and tracking
|
|
596
|
+
β βββ index.ts # Utility functions
|
|
597
|
+
βββ props.ts # Centralized props system
|
|
598
|
+
βββ patterns.ts # URL pattern matching
|
|
599
|
+
βββ types.ts # TypeScript definitions
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
### Export Structure
|
|
603
|
+
|
|
604
|
+
```
|
|
605
|
+
stormcloud-video-player/
|
|
606
|
+
βββ index.js # Main entry (auto-detection)
|
|
607
|
+
βββ hls.js # HLS-only entry
|
|
608
|
+
βββ file.js # File-only entry
|
|
609
|
+
βββ base.d.ts # Base type definitions
|
|
610
|
+
βββ hls.d.ts # HLS-specific types
|
|
611
|
+
βββ file.d.ts # File-specific types
|
|
612
|
+
βββ lib/ # Compiled library
|
|
613
|
+
βββ dist/ # UMD bundles
|
|
614
|
+
βββ scripts/ # Build utilities
|
|
304
615
|
```
|
|
305
616
|
|
|
306
617
|
## π― Use Cases
|
|
307
618
|
|
|
619
|
+
### By Player Type
|
|
620
|
+
|
|
621
|
+
#### HlsPlayer Use Cases
|
|
622
|
+
|
|
308
623
|
- **Live Streaming**: Sports, news, and event broadcasts
|
|
624
|
+
- **Live Shopping**: E-commerce live streams with ads
|
|
625
|
+
- **FAST Channels**: Free ad-supported streaming TV
|
|
626
|
+
- **Linear TV**: Traditional broadcast over IP
|
|
627
|
+
- **Event Streaming**: Conferences, concerts, webinars
|
|
628
|
+
|
|
629
|
+
#### FilePlayer Use Cases
|
|
630
|
+
|
|
309
631
|
- **VOD Platforms**: Movie and series streaming services
|
|
310
632
|
- **Educational Content**: E-learning and training platforms
|
|
311
|
-
- **Corporate Communications**: Internal and
|
|
633
|
+
- **Corporate Communications**: Internal videos and presentations
|
|
312
634
|
- **Digital Signage**: Retail and public display systems
|
|
635
|
+
- **Social Media**: User-generated content playback
|
|
636
|
+
|
|
637
|
+
### Migration Guide
|
|
638
|
+
|
|
639
|
+
#### From Legacy Component
|
|
640
|
+
|
|
641
|
+
```jsx
|
|
642
|
+
// Old way (still works)
|
|
643
|
+
import { StormcloudVideoPlayerComponent } from "stormcloud-video-player";
|
|
644
|
+
|
|
645
|
+
<StormcloudVideoPlayerComponent
|
|
646
|
+
src="https://example.com/stream.m3u8"
|
|
647
|
+
autoplay={true}
|
|
648
|
+
// ... other props
|
|
649
|
+
/>;
|
|
650
|
+
|
|
651
|
+
// New way (recommended for new projects)
|
|
652
|
+
import StormcloudPlayer from "stormcloud-video-player";
|
|
653
|
+
|
|
654
|
+
<StormcloudPlayer
|
|
655
|
+
src="https://example.com/stream.m3u8"
|
|
656
|
+
playing={true} // Note: 'playing' instead of 'autoplay'
|
|
657
|
+
// ... other props
|
|
658
|
+
/>;
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
#### Key Differences
|
|
662
|
+
|
|
663
|
+
| Legacy Component | New Component | Notes |
|
|
664
|
+
| ------------------------ | -------------------------- | --------------------------- |
|
|
665
|
+
| `autoplay={true}` | `playing={true}` | More React-like prop naming |
|
|
666
|
+
| Always loads full bundle | Supports optimized imports | Better performance |
|
|
667
|
+
| Single component | Modular architecture | More maintainable |
|
|
668
|
+
| Fixed UI structure | Flexible wrapper system | More customizable |
|
|
313
669
|
|
|
314
670
|
## β οΈ Known Limitations
|
|
315
671
|
|
|
@@ -317,6 +673,7 @@ src/
|
|
|
317
673
|
- SCTE-35 binary splice parsing not yet implemented
|
|
318
674
|
- Multi-ad pod competitive separation handled by ad server
|
|
319
675
|
- Low-latency HLS (LL-HLS) optimizations in development
|
|
676
|
+
- Picture-in-Picture only available in FilePlayer
|
|
320
677
|
|
|
321
678
|
## πΊοΈ Roadmap
|
|
322
679
|
|
|
@@ -329,6 +686,7 @@ src/
|
|
|
329
686
|
- **UI Themes**: Multiple control themes and color schemes
|
|
330
687
|
- **Accessibility**: Enhanced ARIA support and keyboard navigation
|
|
331
688
|
- **Error Recovery**: Advanced retry logic and failover handling
|
|
689
|
+
- **More Players**: DASH, YouTube, Vimeo player implementations
|
|
332
690
|
|
|
333
691
|
### Performance Improvements
|
|
334
692
|
|
|
@@ -336,6 +694,7 @@ src/
|
|
|
336
694
|
- Memory optimization for long-running sessions
|
|
337
695
|
- Network bandwidth adaptation
|
|
338
696
|
- Smart preloading strategies
|
|
697
|
+
- Code splitting and lazy loading optimizations
|
|
339
698
|
|
|
340
699
|
## π€ Contributing
|
|
341
700
|
|
|
@@ -348,3 +707,14 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
348
707
|
---
|
|
349
708
|
|
|
350
709
|
Built with β€οΈ by the Stormcloud team
|
|
710
|
+
|
|
711
|
+
### What's New in v2.0
|
|
712
|
+
|
|
713
|
+
- π― **Professional Architecture**: Modular player system inspired by react-player
|
|
714
|
+
- π **Automatic Format Detection**: Smart player selection based on video source
|
|
715
|
+
- π¦ **Optimized Bundles**: Import only what you need (HLS-only, File-only, or Full)
|
|
716
|
+
- π **Backward Compatibility**: Legacy component still works without changes
|
|
717
|
+
- π¨ **Enhanced Controls**: Improved UI with better accessibility and design
|
|
718
|
+
- π **Better TypeScript**: Comprehensive type definitions and IntelliSense
|
|
719
|
+
- ποΈ **Extensible**: Easy to add custom players for new formats
|
|
720
|
+
- β‘ **Performance**: Lazy loading and code splitting for faster load times
|