@scarlett-player/hls 0.4.0 → 0.5.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-CBBDW7UR.js → chunk-I4BGO7UY.js} +4 -0
- package/dist/index.cjs +20 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +19 -2
- package/dist/light.cjs +17 -0
- package/dist/light.d.cts +2 -2
- package/dist/light.d.ts +2 -2
- package/dist/light.js +16 -1
- package/dist/{types-Co8zOXVb.d.cts → types-Df2TUpPu.d.cts} +1 -1
- package/dist/{types-Co8zOXVb.d.ts → types-Df2TUpPu.d.ts} +1 -1
- package/package.json +3 -3
|
@@ -149,6 +149,9 @@ function setupVideoEventHandlers(video, api) {
|
|
|
149
149
|
video.addEventListener(event, handler);
|
|
150
150
|
handlers.push({ event, handler });
|
|
151
151
|
};
|
|
152
|
+
addHandler("play", () => {
|
|
153
|
+
api.setState("paused", false);
|
|
154
|
+
});
|
|
152
155
|
addHandler("playing", () => {
|
|
153
156
|
api.setState("playing", true);
|
|
154
157
|
api.setState("paused", false);
|
|
@@ -257,6 +260,7 @@ function setupVideoEventHandlers(video, api) {
|
|
|
257
260
|
}
|
|
258
261
|
|
|
259
262
|
export {
|
|
263
|
+
formatLevel,
|
|
260
264
|
mapLevels,
|
|
261
265
|
setupHlsEventHandlers,
|
|
262
266
|
setupVideoEventHandlers
|
package/dist/index.cjs
CHANGED
|
@@ -238,6 +238,9 @@ function setupVideoEventHandlers(video, api) {
|
|
|
238
238
|
video.addEventListener(event, handler);
|
|
239
239
|
handlers.push({ event, handler });
|
|
240
240
|
};
|
|
241
|
+
addHandler("play", () => {
|
|
242
|
+
api.setState("paused", false);
|
|
243
|
+
});
|
|
241
244
|
addHandler("playing", () => {
|
|
242
245
|
api.setState("playing", true);
|
|
243
246
|
api.setState("paused", false);
|
|
@@ -440,7 +443,9 @@ function createHLSPlugin(config) {
|
|
|
440
443
|
const getRetryDelay = (retryCount) => {
|
|
441
444
|
const baseDelay = mergedConfig.retryDelayMs ?? 1e3;
|
|
442
445
|
const backoffFactor = mergedConfig.retryBackoffFactor ?? 2;
|
|
443
|
-
|
|
446
|
+
const delay = baseDelay * Math.pow(backoffFactor, retryCount);
|
|
447
|
+
const jitter = delay * (0.7 + Math.random() * 0.3);
|
|
448
|
+
return jitter;
|
|
444
449
|
};
|
|
445
450
|
const emitFatalError = (error, retriesExhausted) => {
|
|
446
451
|
const message = retriesExhausted ? `HLS error: ${error.details} (max retries exceeded)` : `HLS error: ${error.details}`;
|
|
@@ -654,6 +659,20 @@ function createHLSPlugin(config) {
|
|
|
654
659
|
if (!isNaN(levelIndex) && levelIndex >= 0 && levelIndex < hls.levels.length) {
|
|
655
660
|
hls.nextLevel = levelIndex;
|
|
656
661
|
api?.logger.debug(`Quality: queued switch to level ${levelIndex}`);
|
|
662
|
+
const targetLevel = hls.levels[levelIndex];
|
|
663
|
+
if (targetLevel) {
|
|
664
|
+
const label = formatLevel(targetLevel);
|
|
665
|
+
api?.setState("currentQuality", {
|
|
666
|
+
id: `level-${levelIndex}`,
|
|
667
|
+
label: `${label}...`,
|
|
668
|
+
// Ellipsis indicates switching in progress
|
|
669
|
+
width: targetLevel.width,
|
|
670
|
+
height: targetLevel.height,
|
|
671
|
+
bitrate: targetLevel.bitrate,
|
|
672
|
+
active: false
|
|
673
|
+
// Not yet active
|
|
674
|
+
});
|
|
675
|
+
}
|
|
657
676
|
}
|
|
658
677
|
}
|
|
659
678
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-Df2TUpPu.cjs';
|
|
2
|
+
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-Df2TUpPu.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 {
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-Df2TUpPu.js';
|
|
2
|
+
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-Df2TUpPu.js';
|
|
3
3
|
import '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
formatLevel,
|
|
2
3
|
mapLevels,
|
|
3
4
|
setupHlsEventHandlers,
|
|
4
5
|
setupVideoEventHandlers
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-I4BGO7UY.js";
|
|
6
7
|
|
|
7
8
|
// src/hls-loader.ts
|
|
8
9
|
var hlsConstructor = null;
|
|
@@ -151,7 +152,9 @@ function createHLSPlugin(config) {
|
|
|
151
152
|
const getRetryDelay = (retryCount) => {
|
|
152
153
|
const baseDelay = mergedConfig.retryDelayMs ?? 1e3;
|
|
153
154
|
const backoffFactor = mergedConfig.retryBackoffFactor ?? 2;
|
|
154
|
-
|
|
155
|
+
const delay = baseDelay * Math.pow(backoffFactor, retryCount);
|
|
156
|
+
const jitter = delay * (0.7 + Math.random() * 0.3);
|
|
157
|
+
return jitter;
|
|
155
158
|
};
|
|
156
159
|
const emitFatalError = (error, retriesExhausted) => {
|
|
157
160
|
const message = retriesExhausted ? `HLS error: ${error.details} (max retries exceeded)` : `HLS error: ${error.details}`;
|
|
@@ -365,6 +368,20 @@ function createHLSPlugin(config) {
|
|
|
365
368
|
if (!isNaN(levelIndex) && levelIndex >= 0 && levelIndex < hls.levels.length) {
|
|
366
369
|
hls.nextLevel = levelIndex;
|
|
367
370
|
api?.logger.debug(`Quality: queued switch to level ${levelIndex}`);
|
|
371
|
+
const targetLevel = hls.levels[levelIndex];
|
|
372
|
+
if (targetLevel) {
|
|
373
|
+
const label = formatLevel(targetLevel);
|
|
374
|
+
api?.setState("currentQuality", {
|
|
375
|
+
id: `level-${levelIndex}`,
|
|
376
|
+
label: `${label}...`,
|
|
377
|
+
// Ellipsis indicates switching in progress
|
|
378
|
+
width: targetLevel.width,
|
|
379
|
+
height: targetLevel.height,
|
|
380
|
+
bitrate: targetLevel.bitrate,
|
|
381
|
+
active: false
|
|
382
|
+
// Not yet active
|
|
383
|
+
});
|
|
384
|
+
}
|
|
368
385
|
}
|
|
369
386
|
}
|
|
370
387
|
});
|
package/dist/light.cjs
CHANGED
|
@@ -238,6 +238,9 @@ function setupVideoEventHandlers(video, api) {
|
|
|
238
238
|
video.addEventListener(event, handler);
|
|
239
239
|
handlers.push({ event, handler });
|
|
240
240
|
};
|
|
241
|
+
addHandler("play", () => {
|
|
242
|
+
api.setState("paused", false);
|
|
243
|
+
});
|
|
241
244
|
addHandler("playing", () => {
|
|
242
245
|
api.setState("playing", true);
|
|
243
246
|
api.setState("paused", false);
|
|
@@ -647,6 +650,20 @@ function createHLSPlugin(config) {
|
|
|
647
650
|
if (!isNaN(levelIndex) && levelIndex >= 0 && levelIndex < hls.levels.length) {
|
|
648
651
|
hls.nextLevel = levelIndex;
|
|
649
652
|
api?.logger.debug(`Quality: queued switch to level ${levelIndex}`);
|
|
653
|
+
const targetLevel = hls.levels[levelIndex];
|
|
654
|
+
if (targetLevel) {
|
|
655
|
+
const label = formatLevel(targetLevel);
|
|
656
|
+
api?.setState("currentQuality", {
|
|
657
|
+
id: `level-${levelIndex}`,
|
|
658
|
+
label: `${label}...`,
|
|
659
|
+
// Ellipsis indicates switching in progress
|
|
660
|
+
width: targetLevel.width,
|
|
661
|
+
height: targetLevel.height,
|
|
662
|
+
bitrate: targetLevel.bitrate,
|
|
663
|
+
active: false
|
|
664
|
+
// Not yet active
|
|
665
|
+
});
|
|
666
|
+
}
|
|
650
667
|
}
|
|
651
668
|
}
|
|
652
669
|
});
|
package/dist/light.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-Df2TUpPu.cjs';
|
|
2
|
+
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-Df2TUpPu.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 {
|
|
1
|
+
import { H as HLSPluginConfig, I as IHLSPlugin } from './types-Df2TUpPu.js';
|
|
2
|
+
export { a as HLSError, b as HLSLiveInfo, c as HLSQualityLevel } from './types-Df2TUpPu.js';
|
|
3
3
|
import '@scarlett-player/core';
|
|
4
4
|
|
|
5
5
|
/**
|
package/dist/light.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
formatLevel,
|
|
2
3
|
mapLevels,
|
|
3
4
|
setupHlsEventHandlers,
|
|
4
5
|
setupVideoEventHandlers
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-I4BGO7UY.js";
|
|
6
7
|
|
|
7
8
|
// src/hls-loader-light.ts
|
|
8
9
|
var hlsConstructor = null;
|
|
@@ -358,6 +359,20 @@ function createHLSPlugin(config) {
|
|
|
358
359
|
if (!isNaN(levelIndex) && levelIndex >= 0 && levelIndex < hls.levels.length) {
|
|
359
360
|
hls.nextLevel = levelIndex;
|
|
360
361
|
api?.logger.debug(`Quality: queued switch to level ${levelIndex}`);
|
|
362
|
+
const targetLevel = hls.levels[levelIndex];
|
|
363
|
+
if (targetLevel) {
|
|
364
|
+
const label = formatLevel(targetLevel);
|
|
365
|
+
api?.setState("currentQuality", {
|
|
366
|
+
id: `level-${levelIndex}`,
|
|
367
|
+
label: `${label}...`,
|
|
368
|
+
// Ellipsis indicates switching in progress
|
|
369
|
+
width: targetLevel.width,
|
|
370
|
+
height: targetLevel.height,
|
|
371
|
+
bitrate: targetLevel.bitrate,
|
|
372
|
+
active: false
|
|
373
|
+
// Not yet active
|
|
374
|
+
});
|
|
375
|
+
}
|
|
361
376
|
}
|
|
362
377
|
}
|
|
363
378
|
});
|
|
@@ -98,4 +98,4 @@ interface IHLSPlugin extends Plugin<HLSPluginConfig> {
|
|
|
98
98
|
switchToHlsJs(): Promise<void>;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export type { HLSPluginConfig as H, IHLSPlugin as I,
|
|
101
|
+
export type { HLSPluginConfig as H, IHLSPlugin as I, HLSError as a, HLSLiveInfo as b, HLSQualityLevel as c };
|
|
@@ -98,4 +98,4 @@ interface IHLSPlugin extends Plugin<HLSPluginConfig> {
|
|
|
98
98
|
switchToHlsJs(): Promise<void>;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export type { HLSPluginConfig as H, IHLSPlugin as I,
|
|
101
|
+
export type { HLSPluginConfig as H, IHLSPlugin as I, HLSError as a, HLSLiveInfo as b, HLSQualityLevel as c };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scarlett-player/hls",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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": "^0.5.0",
|
|
26
26
|
"hls.js": "^1.4.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": "0.5.0"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"video",
|