@scarlett-player/hls 1.1.1 → 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 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
- - Automatic hls.js loading
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
- // hls.js config options
39
- hlsConfig: {
40
- maxBufferLength: 30,
41
- maxMaxBufferLength: 600,
42
- },
43
- // Prefer native HLS when available (Safari)
44
- preferNativeHLS: false,
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