@give-tech/ec-player 0.0.1-beta.55 → 0.0.1-beta.57
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/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/player/HLSPlayer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2617,7 +2617,31 @@ class HLSPlayer extends BasePlayer {
|
|
|
2617
2617
|
}
|
|
2618
2618
|
let content;
|
|
2619
2619
|
try {
|
|
2620
|
-
|
|
2620
|
+
const M3U8_READ_TIMEOUT = 15e3;
|
|
2621
|
+
const body = response.body;
|
|
2622
|
+
if (body) {
|
|
2623
|
+
const reader = body.getReader();
|
|
2624
|
+
const decoder = new TextDecoder();
|
|
2625
|
+
let text = "";
|
|
2626
|
+
const startTime = Date.now();
|
|
2627
|
+
while (true) {
|
|
2628
|
+
if (this.abortController?.signal.aborted) {
|
|
2629
|
+
reader.cancel();
|
|
2630
|
+
throw new DOMException("Aborted", "AbortError");
|
|
2631
|
+
}
|
|
2632
|
+
const { done, value } = await reader.read();
|
|
2633
|
+
if (done) break;
|
|
2634
|
+
text += decoder.decode(value, { stream: true });
|
|
2635
|
+
if (text.includes("#EXT-X-ENDLIST")) break;
|
|
2636
|
+
if (Date.now() - startTime > M3U8_READ_TIMEOUT || text.length > 5e4) break;
|
|
2637
|
+
}
|
|
2638
|
+
content = text + decoder.decode();
|
|
2639
|
+
if (Date.now() - startTime > M3U8_READ_TIMEOUT || !text.includes("#EXT-X-ENDLIST")) {
|
|
2640
|
+
console.log("[parsePlaylist] m3u8 streaming read completed, size:", content.length, "hasEndList:", text.includes("#EXT-X-ENDLIST"));
|
|
2641
|
+
}
|
|
2642
|
+
} else {
|
|
2643
|
+
content = await response.text();
|
|
2644
|
+
}
|
|
2621
2645
|
} catch (error) {
|
|
2622
2646
|
throw error;
|
|
2623
2647
|
}
|
|
@@ -4423,7 +4447,7 @@ class Canvas2DRenderer {
|
|
|
4423
4447
|
render(frame) {
|
|
4424
4448
|
if (!frame || !frame.data) return;
|
|
4425
4449
|
const { width, height, data } = frame;
|
|
4426
|
-
if (this.canvas.width !== width || this.canvas.height !== height) {
|
|
4450
|
+
if (this.canvas.width !== width || this.canvas.height !== height || !this.cachedImageData) {
|
|
4427
4451
|
this.canvas.width = width;
|
|
4428
4452
|
this.canvas.height = height;
|
|
4429
4453
|
this.cachedImageData = this.ctx.createImageData(width, height);
|