@scarlett-player/hls 0.5.3 → 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.
- package/dist/{chunk-5JANLXKE.js → chunk-OEPNMGNQ.js} +21 -0
- package/dist/index.cjs +27 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9 -2
- package/dist/light.cjs +8 -0
- package/dist/light.d.cts +2 -2
- package/dist/light.d.ts +2 -2
- package/dist/light.js +1 -1
- package/dist/{types-Df2TUpPu.d.cts → types-CRKmNxEW.d.cts} +4 -0
- package/dist/{types-Df2TUpPu.d.ts → types-CRKmNxEW.d.ts} +4 -0
- package/package.json +3 -3
|
@@ -44,6 +44,18 @@ function mapLevels(levels, _currentLevel) {
|
|
|
44
44
|
codec: level.codecSet
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
|
+
function getInitialBandwidthEstimate(overrideBps) {
|
|
48
|
+
const HLS_DEFAULT_ESTIMATE = 5e5;
|
|
49
|
+
if (overrideBps !== void 0 && overrideBps > 0) {
|
|
50
|
+
return overrideBps;
|
|
51
|
+
}
|
|
52
|
+
const connection = navigator.connection;
|
|
53
|
+
if (connection?.downlink && connection.downlink > 0) {
|
|
54
|
+
const bps = connection.downlink * 1e6;
|
|
55
|
+
return Math.round(bps * 0.85);
|
|
56
|
+
}
|
|
57
|
+
return HLS_DEFAULT_ESTIMATE;
|
|
58
|
+
}
|
|
47
59
|
|
|
48
60
|
// src/event-map.ts
|
|
49
61
|
var HLS_ERROR_TYPES = {
|
|
@@ -118,6 +130,14 @@ function setupHlsEventHandlers(hls, api, callbacks) {
|
|
|
118
130
|
});
|
|
119
131
|
callbacks.onLevelSwitched?.(data.level);
|
|
120
132
|
});
|
|
133
|
+
let lastBandwidthUpdate = 0;
|
|
134
|
+
addHandler("hlsFragLoaded", () => {
|
|
135
|
+
const now = Date.now();
|
|
136
|
+
if (now - lastBandwidthUpdate >= 2e3 && hls.bandwidthEstimate) {
|
|
137
|
+
lastBandwidthUpdate = now;
|
|
138
|
+
api.setState("bandwidth", Math.round(hls.bandwidthEstimate));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
121
141
|
addHandler("hlsFragBuffered", () => {
|
|
122
142
|
api.setState("buffering", false);
|
|
123
143
|
callbacks.onBufferUpdate?.();
|
|
@@ -305,6 +325,7 @@ function setupVideoEventHandlers(video, api) {
|
|
|
305
325
|
export {
|
|
306
326
|
formatLevel,
|
|
307
327
|
mapLevels,
|
|
328
|
+
getInitialBandwidthEstimate,
|
|
308
329
|
setupHlsEventHandlers,
|
|
309
330
|
setupVideoEventHandlers
|
|
310
331
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -133,6 +133,18 @@ function mapLevels(levels, _currentLevel) {
|
|
|
133
133
|
codec: level.codecSet
|
|
134
134
|
}));
|
|
135
135
|
}
|
|
136
|
+
function getInitialBandwidthEstimate(overrideBps) {
|
|
137
|
+
const HLS_DEFAULT_ESTIMATE = 5e5;
|
|
138
|
+
if (overrideBps !== void 0 && overrideBps > 0) {
|
|
139
|
+
return overrideBps;
|
|
140
|
+
}
|
|
141
|
+
const connection = navigator.connection;
|
|
142
|
+
if (connection?.downlink && connection.downlink > 0) {
|
|
143
|
+
const bps = connection.downlink * 1e6;
|
|
144
|
+
return Math.round(bps * 0.85);
|
|
145
|
+
}
|
|
146
|
+
return HLS_DEFAULT_ESTIMATE;
|
|
147
|
+
}
|
|
136
148
|
|
|
137
149
|
// src/event-map.ts
|
|
138
150
|
var HLS_ERROR_TYPES = {
|
|
@@ -207,6 +219,14 @@ function setupHlsEventHandlers(hls, api, callbacks) {
|
|
|
207
219
|
});
|
|
208
220
|
callbacks.onLevelSwitched?.(data.level);
|
|
209
221
|
});
|
|
222
|
+
let lastBandwidthUpdate = 0;
|
|
223
|
+
addHandler("hlsFragLoaded", () => {
|
|
224
|
+
const now = Date.now();
|
|
225
|
+
if (now - lastBandwidthUpdate >= 2e3 && hls.bandwidthEstimate) {
|
|
226
|
+
lastBandwidthUpdate = now;
|
|
227
|
+
api.setState("bandwidth", Math.round(hls.bandwidthEstimate));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
210
230
|
addHandler("hlsFragBuffered", () => {
|
|
211
231
|
api.setState("buffering", false);
|
|
212
232
|
callbacks.onBufferUpdate?.();
|
|
@@ -401,6 +421,7 @@ var DEFAULT_CONFIG = {
|
|
|
401
421
|
maxMaxBufferLength: 600,
|
|
402
422
|
backBufferLength: 30,
|
|
403
423
|
enableWorker: true,
|
|
424
|
+
capLevelToPlayerSize: true,
|
|
404
425
|
// Error recovery settings
|
|
405
426
|
maxNetworkRetries: 3,
|
|
406
427
|
maxMediaRetries: 2,
|
|
@@ -470,11 +491,13 @@ function createHLSPlugin(config) {
|
|
|
470
491
|
startPosition: mergedConfig.startPosition,
|
|
471
492
|
startLevel: -1,
|
|
472
493
|
// Auto quality selection (ABR)
|
|
494
|
+
abrEwmaDefaultEstimate: getInitialBandwidthEstimate(mergedConfig.initialBandwidthEstimate),
|
|
473
495
|
lowLatencyMode: mergedConfig.lowLatencyMode,
|
|
474
496
|
maxBufferLength: mergedConfig.maxBufferLength,
|
|
475
497
|
maxMaxBufferLength: mergedConfig.maxMaxBufferLength,
|
|
476
498
|
backBufferLength: mergedConfig.backBufferLength,
|
|
477
499
|
enableWorker: mergedConfig.enableWorker,
|
|
500
|
+
capLevelToPlayerSize: mergedConfig.capLevelToPlayerSize,
|
|
478
501
|
// Minimize hls.js internal retries - we handle retries ourselves
|
|
479
502
|
fragLoadingMaxRetry: 1,
|
|
480
503
|
manifestLoadingMaxRetry: 1,
|
|
@@ -745,7 +768,10 @@ function createHLSPlugin(config) {
|
|
|
745
768
|
currentSrc = src;
|
|
746
769
|
api.setState("playbackState", "loading");
|
|
747
770
|
api.setState("buffering", true);
|
|
748
|
-
if (
|
|
771
|
+
if (api.getState("airplayActive") && supportsNativeHLS()) {
|
|
772
|
+
api.logger.info("Using native HLS (AirPlay active)");
|
|
773
|
+
await loadNative(src);
|
|
774
|
+
} else if (isHlsJsSupported()) {
|
|
749
775
|
api.logger.info("Using hls.js for HLS playback");
|
|
750
776
|
await loadWithHlsJs(src);
|
|
751
777
|
} else if (supportsNativeHLS()) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-
|
|
2
|
-
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-CRKmNxEW.cjs';
|
|
2
|
+
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-CRKmNxEW.cjs';
|
|
3
3
|
import '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-
|
|
2
|
-
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-CRKmNxEW.js';
|
|
2
|
+
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-CRKmNxEW.js';
|
|
3
3
|
import '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatLevel,
|
|
3
|
+
getInitialBandwidthEstimate,
|
|
3
4
|
mapLevels,
|
|
4
5
|
setupHlsEventHandlers,
|
|
5
6
|
setupVideoEventHandlers
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OEPNMGNQ.js";
|
|
7
8
|
|
|
8
9
|
// src/hls-loader.ts
|
|
9
10
|
var hlsConstructor = null;
|
|
@@ -67,6 +68,7 @@ var DEFAULT_CONFIG = {
|
|
|
67
68
|
maxMaxBufferLength: 600,
|
|
68
69
|
backBufferLength: 30,
|
|
69
70
|
enableWorker: true,
|
|
71
|
+
capLevelToPlayerSize: true,
|
|
70
72
|
// Error recovery settings
|
|
71
73
|
maxNetworkRetries: 3,
|
|
72
74
|
maxMediaRetries: 2,
|
|
@@ -136,11 +138,13 @@ function createHLSPlugin(config) {
|
|
|
136
138
|
startPosition: mergedConfig.startPosition,
|
|
137
139
|
startLevel: -1,
|
|
138
140
|
// Auto quality selection (ABR)
|
|
141
|
+
abrEwmaDefaultEstimate: getInitialBandwidthEstimate(mergedConfig.initialBandwidthEstimate),
|
|
139
142
|
lowLatencyMode: mergedConfig.lowLatencyMode,
|
|
140
143
|
maxBufferLength: mergedConfig.maxBufferLength,
|
|
141
144
|
maxMaxBufferLength: mergedConfig.maxMaxBufferLength,
|
|
142
145
|
backBufferLength: mergedConfig.backBufferLength,
|
|
143
146
|
enableWorker: mergedConfig.enableWorker,
|
|
147
|
+
capLevelToPlayerSize: mergedConfig.capLevelToPlayerSize,
|
|
144
148
|
// Minimize hls.js internal retries - we handle retries ourselves
|
|
145
149
|
fragLoadingMaxRetry: 1,
|
|
146
150
|
manifestLoadingMaxRetry: 1,
|
|
@@ -411,7 +415,10 @@ function createHLSPlugin(config) {
|
|
|
411
415
|
currentSrc = src;
|
|
412
416
|
api.setState("playbackState", "loading");
|
|
413
417
|
api.setState("buffering", true);
|
|
414
|
-
if (
|
|
418
|
+
if (api.getState("airplayActive") && supportsNativeHLS()) {
|
|
419
|
+
api.logger.info("Using native HLS (AirPlay active)");
|
|
420
|
+
await loadNative(src);
|
|
421
|
+
} else if (isHlsJsSupported()) {
|
|
415
422
|
api.logger.info("Using hls.js for HLS playback");
|
|
416
423
|
await loadWithHlsJs(src);
|
|
417
424
|
} else if (supportsNativeHLS()) {
|
package/dist/light.cjs
CHANGED
|
@@ -207,6 +207,14 @@ function setupHlsEventHandlers(hls, api, callbacks) {
|
|
|
207
207
|
});
|
|
208
208
|
callbacks.onLevelSwitched?.(data.level);
|
|
209
209
|
});
|
|
210
|
+
let lastBandwidthUpdate = 0;
|
|
211
|
+
addHandler("hlsFragLoaded", () => {
|
|
212
|
+
const now = Date.now();
|
|
213
|
+
if (now - lastBandwidthUpdate >= 2e3 && hls.bandwidthEstimate) {
|
|
214
|
+
lastBandwidthUpdate = now;
|
|
215
|
+
api.setState("bandwidth", Math.round(hls.bandwidthEstimate));
|
|
216
|
+
}
|
|
217
|
+
});
|
|
210
218
|
addHandler("hlsFragBuffered", () => {
|
|
211
219
|
api.setState("buffering", false);
|
|
212
220
|
callbacks.onBufferUpdate?.();
|
package/dist/light.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-
|
|
2
|
-
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-CRKmNxEW.cjs';
|
|
2
|
+
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-CRKmNxEW.cjs';
|
|
3
3
|
import '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/light.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-
|
|
2
|
-
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-CRKmNxEW.js';
|
|
2
|
+
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-CRKmNxEW.js';
|
|
3
3
|
import '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/light.js
CHANGED
|
@@ -26,6 +26,10 @@ interface HLSPluginConfig {
|
|
|
26
26
|
maxNetworkRetries?: number;
|
|
27
27
|
/** Max media error retries before giving up (default: 2) */
|
|
28
28
|
maxMediaRetries?: number;
|
|
29
|
+
/** Cap quality to player element dimensions (default: true) */
|
|
30
|
+
capLevelToPlayerSize?: boolean;
|
|
31
|
+
/** Override initial bandwidth estimate in bits per second */
|
|
32
|
+
initialBandwidthEstimate?: number;
|
|
29
33
|
/** Base retry delay in milliseconds (default: 1000) */
|
|
30
34
|
retryDelayMs?: number;
|
|
31
35
|
/** Exponential backoff multiplier (default: 2) */
|
|
@@ -26,6 +26,10 @@ interface HLSPluginConfig {
|
|
|
26
26
|
maxNetworkRetries?: number;
|
|
27
27
|
/** Max media error retries before giving up (default: 2) */
|
|
28
28
|
maxMediaRetries?: number;
|
|
29
|
+
/** Cap quality to player element dimensions (default: true) */
|
|
30
|
+
capLevelToPlayerSize?: boolean;
|
|
31
|
+
/** Override initial bandwidth estimate in bits per second */
|
|
32
|
+
initialBandwidthEstimate?: number;
|
|
29
33
|
/** Base retry delay in milliseconds (default: 1000) */
|
|
30
34
|
retryDelayMs?: number;
|
|
31
35
|
/** Exponential backoff multiplier (default: 2) */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scarlett-player/hls",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "HLS Provider Plugin for Scarlett Player",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@scarlett-player/core": "^0.
|
|
25
|
+
"@scarlett-player/core": "^1.0.0",
|
|
26
26
|
"hls.js": "^1.5.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependenciesMeta": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"vitest": "^1.6.0",
|
|
38
38
|
"@vitest/coverage-v8": "^1.6.0",
|
|
39
39
|
"jsdom": "^24.0.0",
|
|
40
|
-
"@scarlett-player/core": "0.
|
|
40
|
+
"@scarlett-player/core": "1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"video",
|