hls.js 1.6.0-beta.1.0.canary.10752 → 1.6.0-beta.1.0.canary.10756
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/hls.js +50 -42
- package/dist/hls.js.map +1 -1
- package/dist/hls.light.js +44 -40
- package/dist/hls.light.js.map +1 -1
- package/dist/hls.light.min.js +1 -1
- package/dist/hls.light.min.js.map +1 -1
- package/dist/hls.light.mjs +44 -40
- package/dist/hls.light.mjs.map +1 -1
- package/dist/hls.min.js +1 -1
- package/dist/hls.min.js.map +1 -1
- package/dist/hls.mjs +50 -42
- package/dist/hls.mjs.map +1 -1
- package/dist/hls.worker.js +1 -1
- package/package.json +2 -2
- package/src/controller/audio-track-controller.ts +8 -2
- package/src/utils/xhr-loader.ts +52 -49
package/src/utils/xhr-loader.ts
CHANGED
@@ -204,59 +204,62 @@ class XhrLoader implements Loader<LoaderContext> {
|
|
204
204
|
xhr.onprogress = null;
|
205
205
|
const status = xhr.status;
|
206
206
|
// http status between 200 to 299 are all successful
|
207
|
-
const
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
(
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
207
|
+
const useResponseText =
|
208
|
+
xhr.responseType === 'text' ? xhr.responseText : null;
|
209
|
+
if (status >= 200 && status < 300) {
|
210
|
+
const data = useResponseText ?? xhr.response;
|
211
|
+
if (data != null) {
|
212
|
+
stats.loading.end = Math.max(
|
213
|
+
self.performance.now(),
|
214
|
+
stats.loading.first,
|
215
|
+
);
|
216
|
+
const len =
|
217
|
+
xhr.responseType === 'arraybuffer'
|
218
|
+
? data.byteLength
|
219
|
+
: data.length;
|
220
|
+
stats.loaded = stats.total = len;
|
221
|
+
stats.bwEstimate =
|
222
|
+
(stats.total * 8000) / (stats.loading.end - stats.loading.first);
|
223
|
+
if (!this.callbacks) {
|
224
|
+
return;
|
225
|
+
}
|
226
|
+
const onProgress = this.callbacks.onProgress;
|
227
|
+
if (onProgress) {
|
228
|
+
onProgress(stats, context, data, xhr);
|
229
|
+
}
|
230
|
+
if (!this.callbacks) {
|
231
|
+
return;
|
232
|
+
}
|
233
|
+
const response: LoaderResponse = {
|
234
|
+
url: xhr.responseURL,
|
235
|
+
data: data,
|
236
|
+
code: status,
|
237
|
+
};
|
238
|
+
|
239
|
+
this.callbacks.onSuccess(response, stats, context, xhr);
|
231
240
|
return;
|
232
241
|
}
|
233
|
-
|
234
|
-
url: xhr.responseURL,
|
235
|
-
data: data,
|
236
|
-
code: status,
|
237
|
-
};
|
242
|
+
}
|
238
243
|
|
239
|
-
|
244
|
+
// Handle bad status or nullish response
|
245
|
+
const retryConfig = config.loadPolicy.errorRetry;
|
246
|
+
const retryCount = stats.retry;
|
247
|
+
// if max nb of retries reached or if http status between 400 and 499 (such error cannot be recovered, retrying is useless), return error
|
248
|
+
const response: LoaderResponse = {
|
249
|
+
url: context.url,
|
250
|
+
data: undefined,
|
251
|
+
code: status,
|
252
|
+
};
|
253
|
+
if (shouldRetry(retryConfig, retryCount, false, response)) {
|
254
|
+
this.retry(retryConfig);
|
240
255
|
} else {
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
};
|
249
|
-
if (shouldRetry(retryConfig, retryCount, false, response)) {
|
250
|
-
this.retry(retryConfig);
|
251
|
-
} else {
|
252
|
-
logger.error(`${status} while loading ${context.url}`);
|
253
|
-
this.callbacks!.onError(
|
254
|
-
{ code: status, text: xhr.statusText },
|
255
|
-
context,
|
256
|
-
xhr,
|
257
|
-
stats,
|
258
|
-
);
|
259
|
-
}
|
256
|
+
logger.error(`${status} while loading ${context.url}`);
|
257
|
+
this.callbacks!.onError(
|
258
|
+
{ code: status, text: xhr.statusText },
|
259
|
+
context,
|
260
|
+
xhr,
|
261
|
+
stats,
|
262
|
+
);
|
260
263
|
}
|
261
264
|
}
|
262
265
|
}
|