@nomercy-entertainment/nomercy-video-player 2.6.0 → 2.7.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/CHANGELOG.md +8 -0
- package/dist/adapters/video-backend/IVideoBackend.d.ts +1 -0
- package/dist/adapters/video-backend/html5.js +16 -19
- package/dist/adapters/video-backend/source-outage.d.ts +8 -0
- package/dist/adapters/video-backend/source-outage.js +20 -1
- package/dist/nomercy-video-player.iife.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [2.7.0] — 2026-11-01
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- A failed load carries the HTTP status of the failed request, so `next()` can skip a missing item (404, 410), refresh once on 401 and raise `fatal` on 5xx.
|
|
10
|
+
- The fixed 10 s `waitForLoadedMetadata` limit is gone for every load; the media pipeline's own retry and error events decide.
|
|
11
|
+
- Needs `@nomercy-entertainment/nomercy-player-core` 2.6.0.
|
|
12
|
+
|
|
5
13
|
## [2.6.0] — 2026-11-01
|
|
6
14
|
|
|
7
15
|
### Added
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
//
|
|
6
6
|
// SPDX-License-Identifier: Apache-2.0
|
|
7
7
|
// -----------------------------------------------------------------------------
|
|
8
|
-
import { abrCeiling, appendAuthTokenParam, createAuthorizationXhrSetup, destroyHlsInstance, detectDisplayHdr, hdrDecision, isHls, MediaElementBackend, MediaFormatError, mediaFormatError, panePixels, resetMediaElement, sizeAbrCeiling, supportsNativeHls, } from '@nomercy-entertainment/nomercy-player-core';
|
|
8
|
+
import { abrCeiling, appendAuthTokenParam, createAuthorizationXhrSetup, destroyHlsInstance, detectDisplayHdr, hdrDecision, isHls, MediaElementBackend, MediaFormatError, mediaFormatError, panePixels, resetMediaElement, sizeAbrCeiling, StreamError, supportsNativeHls, } from '@nomercy-entertainment/nomercy-player-core';
|
|
9
9
|
import { createWarmLoader, HlsWarmCache } from './hls-warm-cache.js';
|
|
10
|
-
import {
|
|
10
|
+
import { definiteFailureCode, SOURCE_OUTAGE_BACKOFF_MS, sourceOutageRetryLimit } from './source-outage.js';
|
|
11
11
|
/** Cap on bytes the next-item warmup may hold in memory. */
|
|
12
12
|
const WARM_MAX_BYTES = 24 * 1024 * 1024;
|
|
13
13
|
const CODEC_LABELS = [
|
|
@@ -929,9 +929,12 @@ export class Html5VideoBackend extends MediaElementBackend {
|
|
|
929
929
|
// that, and a consumer can act on it — offer the next item — but only if
|
|
930
930
|
// it is told which failure this was, so it gets its own code rather than
|
|
931
931
|
// the generic network one every outage ends with.
|
|
932
|
-
|
|
932
|
+
const definiteCode = this._sawConnectionFailure
|
|
933
|
+
? undefined
|
|
934
|
+
: definiteFailureCode(httpStatus, this._state === 'loading');
|
|
935
|
+
if (definiteCode) {
|
|
933
936
|
this._recoveringFromOutage = false;
|
|
934
|
-
this._escalateHlsError(
|
|
937
|
+
this._escalateHlsError(definiteCode, `HTTP ${httpStatus}: ${data.details}`, httpStatus);
|
|
935
938
|
return;
|
|
936
939
|
}
|
|
937
940
|
if (this._netRetryCount >= limit) {
|
|
@@ -997,10 +1000,10 @@ export class Html5VideoBackend extends MediaElementBackend {
|
|
|
997
1000
|
* @param details - `HlsErrorData.details` string from hls.js
|
|
998
1001
|
* @param message - Human-readable summary for the error payload
|
|
999
1002
|
*/
|
|
1000
|
-
_escalateHlsError(details, message) {
|
|
1003
|
+
_escalateHlsError(details, message, status) {
|
|
1001
1004
|
this._hadError = true;
|
|
1002
1005
|
this._state = 'error';
|
|
1003
|
-
this.emit('stream:error', { details, fatal: true });
|
|
1006
|
+
this.emit('stream:error', status === undefined ? { details, fatal: true } : { details, fatal: true, status });
|
|
1004
1007
|
// Construct a synthetic error event so the `error` channel stays
|
|
1005
1008
|
// typed as `Event` (BackendEventPayload contract). Consumers that
|
|
1006
1009
|
// want the typed PlayerError should listen on `stream:error`.
|
|
@@ -1335,14 +1338,11 @@ export class Html5VideoBackend extends MediaElementBackend {
|
|
|
1335
1338
|
waitForLoadedMetadata() {
|
|
1336
1339
|
if (this.element.readyState >= 1 /* HAVE_METADATA */)
|
|
1337
1340
|
return Promise.resolve();
|
|
1338
|
-
const METADATA_TIMEOUT_MS = 10_000;
|
|
1339
1341
|
return new Promise((resolve, reject) => {
|
|
1340
|
-
let timer;
|
|
1341
1342
|
let onLoad;
|
|
1342
1343
|
let onElementError;
|
|
1343
1344
|
let onStreamError;
|
|
1344
1345
|
const cleanup = () => {
|
|
1345
|
-
clearTimeout(timer);
|
|
1346
1346
|
this.element.removeEventListener('loadedmetadata', onLoad);
|
|
1347
1347
|
this.element.removeEventListener('error', onElementError);
|
|
1348
1348
|
this.off('stream:error', onStreamError);
|
|
@@ -1361,18 +1361,15 @@ export class Html5VideoBackend extends MediaElementBackend {
|
|
|
1361
1361
|
onStreamError = (data) => {
|
|
1362
1362
|
if (data?.fatal) {
|
|
1363
1363
|
cleanup();
|
|
1364
|
-
reject(new
|
|
1364
|
+
reject(new StreamError({
|
|
1365
|
+
code: data.details,
|
|
1366
|
+
severity: 'error',
|
|
1367
|
+
scope: { kind: 'stream', id: 'hls' },
|
|
1368
|
+
message: `HLS fatal: ${data.details}`,
|
|
1369
|
+
context: data.status === undefined ? undefined : { httpStatus: data.status },
|
|
1370
|
+
}));
|
|
1365
1371
|
}
|
|
1366
1372
|
};
|
|
1367
|
-
// Hard backstop: if neither loadedmetadata nor a fatal error arrives
|
|
1368
|
-
// within METADATA_TIMEOUT_MS, reject so load() never parks indefinitely.
|
|
1369
|
-
// This catches the case where HLS.js retries exhaust slowly (the default
|
|
1370
|
-
// three-retry back-off takes 7 s on manifest 404s) or where a non-fatal
|
|
1371
|
-
// error loop never escalates to fatal at all.
|
|
1372
|
-
timer = setTimeout(() => {
|
|
1373
|
-
cleanup();
|
|
1374
|
-
reject(new Error(`waitForLoadedMetadata timed out after ${METADATA_TIMEOUT_MS} ms`));
|
|
1375
|
-
}, METADATA_TIMEOUT_MS);
|
|
1376
1373
|
this.element.addEventListener('loadedmetadata', onLoad, { once: true });
|
|
1377
1374
|
this.element.addEventListener('error', onElementError, { once: true });
|
|
1378
1375
|
this.on('stream:error', onStreamError);
|
|
@@ -57,6 +57,8 @@ export declare const NO_RETRIES = 0;
|
|
|
57
57
|
* 410 is the same answer said more firmly.
|
|
58
58
|
*/
|
|
59
59
|
export declare function isMediaAbsentStatus(httpStatus: number): boolean;
|
|
60
|
+
/** True for a 5xx from a server that is up (500, 501, 505...), as opposed to an origin-down status. */
|
|
61
|
+
export declare function isServerErrorStatus(httpStatus: number): boolean;
|
|
60
62
|
/**
|
|
61
63
|
* How many rungs this failure is allowed.
|
|
62
64
|
*
|
|
@@ -80,3 +82,9 @@ export declare function sourceOutageRetryLimit(httpStatus: number, sawConnection
|
|
|
80
82
|
* other.
|
|
81
83
|
*/
|
|
82
84
|
export declare const MEDIA_ABSENT = "core:stream/media-absent";
|
|
85
|
+
/** The server answered 5xx while up; the player raises a fatal error. */
|
|
86
|
+
export declare const SERVER_ERROR = "core:stream/server-error";
|
|
87
|
+
/** The media request was refused with 401; the player refreshes the token once. */
|
|
88
|
+
export declare const UNAUTHENTICATED = "core:auth/unauthenticated";
|
|
89
|
+
/** The code for a failure no retry changes, else `undefined`. */
|
|
90
|
+
export declare function definiteFailureCode(httpStatus: number, loading: boolean): string | undefined;
|
|
@@ -77,6 +77,10 @@ export const NO_RETRIES = 0;
|
|
|
77
77
|
export function isMediaAbsentStatus(httpStatus) {
|
|
78
78
|
return httpStatus === 404 || httpStatus === 410;
|
|
79
79
|
}
|
|
80
|
+
/** True for a 5xx from a server that is up (500, 501, 505...), as opposed to an origin-down status. */
|
|
81
|
+
export function isServerErrorStatus(httpStatus) {
|
|
82
|
+
return httpStatus >= 500 && httpStatus <= 599 && !isOriginDownStatus(httpStatus);
|
|
83
|
+
}
|
|
80
84
|
/**
|
|
81
85
|
* How many rungs this failure is allowed.
|
|
82
86
|
*
|
|
@@ -99,7 +103,7 @@ export function sourceOutageRetryLimit(httpStatus, sawConnectionFailure) {
|
|
|
99
103
|
return SOURCE_OUTAGE_BACKOFF_MS.length;
|
|
100
104
|
if (isOriginDownStatus(httpStatus))
|
|
101
105
|
return SOURCE_OUTAGE_BACKOFF_MS.length;
|
|
102
|
-
if (isMediaAbsentStatus(httpStatus))
|
|
106
|
+
if (isMediaAbsentStatus(httpStatus) || isServerErrorStatus(httpStatus))
|
|
103
107
|
return NO_RETRIES;
|
|
104
108
|
if (httpStatus > 0)
|
|
105
109
|
return HTTP_STATUS_RETRY_LIMIT;
|
|
@@ -112,3 +116,18 @@ export function sourceOutageRetryLimit(httpStatus, sawConnectionFailure) {
|
|
|
112
116
|
* other.
|
|
113
117
|
*/
|
|
114
118
|
export const MEDIA_ABSENT = 'core:stream/media-absent';
|
|
119
|
+
/** The server answered 5xx while up; the player raises a fatal error. */
|
|
120
|
+
export const SERVER_ERROR = 'core:stream/server-error';
|
|
121
|
+
/** The media request was refused with 401; the player refreshes the token once. */
|
|
122
|
+
export const UNAUTHENTICATED = 'core:auth/unauthenticated';
|
|
123
|
+
/** The code for a failure no retry changes, else `undefined`. */
|
|
124
|
+
export function definiteFailureCode(httpStatus, loading) {
|
|
125
|
+
if (isMediaAbsentStatus(httpStatus))
|
|
126
|
+
return MEDIA_ABSENT;
|
|
127
|
+
if (isServerErrorStatus(httpStatus))
|
|
128
|
+
return SERVER_ERROR;
|
|
129
|
+
// A 401 counts only while loading: mid-playback the ladder picks up a refreshed token.
|
|
130
|
+
if (httpStatus === 401 && loading)
|
|
131
|
+
return UNAUTHENTICATED;
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|