@scarlett-player/hls 1.0.2 → 1.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 +59 -11
- package/dist/chunk-IFUZZQQE.js +1141 -0
- package/dist/index.cjs +396 -43
- package/dist/index.d.cts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +34 -486
- package/dist/light.cjs +432 -43
- package/dist/light.d.cts +11 -4
- package/dist/light.d.ts +11 -4
- package/dist/light.js +34 -461
- package/dist/{types-CRKmNxEW.d.cts → types-D-HW4lmM.d.cts} +27 -1
- package/dist/{types-CRKmNxEW.d.ts → types-D-HW4lmM.d.ts} +27 -1
- package/package.json +3 -3
- package/dist/chunk-MLOYPPFI.js +0 -336
package/README.md
CHANGED
|
@@ -25,26 +25,74 @@ await player.load('https://example.com/video.m3u8');
|
|
|
25
25
|
|
|
26
26
|
## Features
|
|
27
27
|
|
|
28
|
-
- Adaptive bitrate streaming
|
|
29
|
-
- Quality level selection
|
|
28
|
+
- Adaptive bitrate streaming with quality level selection
|
|
30
29
|
- Live stream support with DVR
|
|
31
|
-
- Native Safari HLS fallback
|
|
32
|
-
-
|
|
30
|
+
- Native Safari HLS fallback (and hls.js lazy loading everywhere else)
|
|
31
|
+
- Self-healing error recovery: bounded retries with jittered backoff,
|
|
32
|
+
auto-reconnect after mid-playback failures (VOD resumes at position, live
|
|
33
|
+
rejoins the edge), and a load watchdog so a dead source never leaves the
|
|
34
|
+
viewer on an endless spinner
|
|
35
|
+
- Playlist refresh validation: a live refresh that returns an error page, a
|
|
36
|
+
master-only response, or an empty document is treated as a transient
|
|
37
|
+
network error instead of being indexed blindly
|
|
38
|
+
- Structured error codes (MEDIA_NETWORK_ERROR, MEDIA_APPEND_ERROR,
|
|
39
|
+
MEDIA_BUFFER_FULL, PLAYLIST_INVALID, ...) so UIs can show accurate copy
|
|
33
40
|
|
|
34
41
|
## Configuration
|
|
35
42
|
|
|
43
|
+
All options are optional; defaults shown.
|
|
44
|
+
|
|
36
45
|
```typescript
|
|
37
46
|
createHLSPlugin({
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
//
|
|
44
|
-
|
|
47
|
+
// Buffering
|
|
48
|
+
maxBufferLength: 30, // Forward buffer target (seconds)
|
|
49
|
+
maxMaxBufferLength: 600, // Hard forward buffer cap (seconds)
|
|
50
|
+
backBufferLength: 30, // Back buffer kept for DVR (seconds)
|
|
51
|
+
enableWorker: true, // Transmux in a Web Worker
|
|
52
|
+
capLevelToPlayerSize: true, // Cap ABR to the player element size
|
|
53
|
+
initialBandwidthEstimate: undefined, // Override initial ABR estimate (bps)
|
|
54
|
+
|
|
55
|
+
// Loading
|
|
56
|
+
autoStartLoad: true,
|
|
57
|
+
startPosition: -1,
|
|
58
|
+
lowLatencyMode: false,
|
|
59
|
+
loadTimeoutMs: 30000, // Load watchdog; 0 disables
|
|
60
|
+
|
|
61
|
+
// Error recovery
|
|
62
|
+
maxNetworkRetries: 3,
|
|
63
|
+
maxMediaRetries: 2,
|
|
64
|
+
retryDelayMs: 1000, // Base backoff delay
|
|
65
|
+
retryBackoffFactor: 2,
|
|
66
|
+
validatePlaylists: true, // Reject malformed playlist refreshes
|
|
67
|
+
|
|
68
|
+
// Auto-reconnect (after a fatal error once playback had started)
|
|
69
|
+
autoReconnect: true,
|
|
70
|
+
reconnectBaseDelayMs: 2000,
|
|
71
|
+
reconnectMaxDelayMs: 30000,
|
|
72
|
+
reconnectWindowMs: 300000, // Keep trying for 5 minutes
|
|
45
73
|
});
|
|
46
74
|
```
|
|
47
75
|
|
|
76
|
+
## Error Recovery
|
|
77
|
+
|
|
78
|
+
Recoverable errors retry with jittered exponential backoff; the retry budget
|
|
79
|
+
restores itself once media flows again, so a long live event's transient blips
|
|
80
|
+
never accumulate into a terminal failure. When retries are exhausted after
|
|
81
|
+
playback had started, the plugin tears down and rebuilds the pipeline
|
|
82
|
+
automatically (emitting `error:reconnecting` and `error:recovered` for the
|
|
83
|
+
UI), and reconnects immediately when the browser comes back online. Only after
|
|
84
|
+
the reconnect window closes does the viewer see the retry UI.
|
|
85
|
+
|
|
86
|
+
## Light Build
|
|
87
|
+
|
|
88
|
+
`@scarlett-player/hls/light` uses hls.js/light (roughly 35% smaller, no
|
|
89
|
+
subtitles, ID3, or DRM support). Both entries wrap the same internal factory,
|
|
90
|
+
so the light build carries identical error handling and recovery.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { createHLSPlugin } from '@scarlett-player/hls/light';
|
|
94
|
+
```
|
|
95
|
+
|
|
48
96
|
## Quality Selection
|
|
49
97
|
|
|
50
98
|
```typescript
|