@give-tech/ec-player 0.0.1-beta.51 → 0.0.1-beta.53
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 +30 -7
- package/dist/index.js.map +1 -1
- package/dist/player/EcPlayerCore.d.ts.map +1 -1
- package/dist/player/FLVPlayer.d.ts +2 -0
- package/dist/player/FLVPlayer.d.ts.map +1 -1
- package/dist/renderer/Canvas2DRenderer.d.ts +3 -0
- package/dist/renderer/Canvas2DRenderer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3370,6 +3370,8 @@ class FLVPlayer extends BasePlayer {
|
|
|
3370
3370
|
this.playStartTimeOffset = 0;
|
|
3371
3371
|
this.resyncCount = 0;
|
|
3372
3372
|
this._lastRafTime = 0;
|
|
3373
|
+
this._prevRenderDts = -1;
|
|
3374
|
+
this._frameIntervalSamples = [];
|
|
3373
3375
|
this.renderLoop = () => {
|
|
3374
3376
|
if (!this.isPlaying) return;
|
|
3375
3377
|
this.updateState({
|
|
@@ -3444,6 +3446,15 @@ class FLVPlayer extends BasePlayer {
|
|
|
3444
3446
|
const frameToRender = this._timedFrameBuffer.shift();
|
|
3445
3447
|
this.renderFrame(frameToRender, now);
|
|
3446
3448
|
this.lastRenderedDts = frameToRender.dts;
|
|
3449
|
+
if (this._prevRenderDts >= 0) {
|
|
3450
|
+
this._frameIntervalSamples.push(frameToRender.dts - this._prevRenderDts);
|
|
3451
|
+
if (this._frameIntervalSamples.length >= 30) {
|
|
3452
|
+
const avg = this._frameIntervalSamples.reduce((a, b) => a + b, 0) / this._frameIntervalSamples.length;
|
|
3453
|
+
console.log("[FLVPlayer] 帧率诊断: 平均帧间隔", avg.toFixed(1), "ms, 约", (1e3 / avg).toFixed(1), "fps, 样本数:", this._frameIntervalSamples.length);
|
|
3454
|
+
this._frameIntervalSamples = [];
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
this._prevRenderDts = frameToRender.dts;
|
|
3447
3458
|
const lag = currentTargetPts - frameToRender.dts;
|
|
3448
3459
|
if (lag > 1e3) {
|
|
3449
3460
|
this.playStartTime = now;
|
|
@@ -3478,8 +3489,6 @@ class FLVPlayer extends BasePlayer {
|
|
|
3478
3489
|
this.consecutiveEmptyBuffer++;
|
|
3479
3490
|
if (isLive && this.bufferEmptyStartTime > 0) {
|
|
3480
3491
|
this.pausedTime = now - this.bufferEmptyStartTime;
|
|
3481
|
-
} else if (!isLive && this.bufferEmptyStartTime > 0) {
|
|
3482
|
-
this.playStartTimeOffset = now - this.bufferEmptyStartTime;
|
|
3483
3492
|
}
|
|
3484
3493
|
if (this.consecutiveEmptyBuffer === 1) {
|
|
3485
3494
|
console.warn("[FLVPlayer] Buffer empty, waiting for frames... queue:", this._videoTagQueue.length);
|
|
@@ -3706,6 +3715,8 @@ class FLVPlayer extends BasePlayer {
|
|
|
3706
3715
|
this.playStartTime = performance.now();
|
|
3707
3716
|
this.playStartTimeOffset = 0;
|
|
3708
3717
|
this._lastRafTime = 0;
|
|
3718
|
+
this._prevRenderDts = -1;
|
|
3719
|
+
this._frameIntervalSamples = [];
|
|
3709
3720
|
console.log("[FLVPlayer] Play time initialized, firstFrameDts:", this.firstFrameDts);
|
|
3710
3721
|
}
|
|
3711
3722
|
this.isPlaying = true;
|
|
@@ -4380,6 +4391,9 @@ class Canvas2DRenderer {
|
|
|
4380
4391
|
this.frameCount = 0;
|
|
4381
4392
|
this.lastFpsUpdate = performance.now();
|
|
4382
4393
|
this.lastFps = 0;
|
|
4394
|
+
this.cachedImageData = null;
|
|
4395
|
+
this.cachedWidth = 0;
|
|
4396
|
+
this.cachedHeight = 0;
|
|
4383
4397
|
this.canvas = canvas;
|
|
4384
4398
|
this.ctx = canvas.getContext("2d");
|
|
4385
4399
|
if (!this.ctx) {
|
|
@@ -4398,8 +4412,13 @@ class Canvas2DRenderer {
|
|
|
4398
4412
|
if (this.canvas.width !== width || this.canvas.height !== height) {
|
|
4399
4413
|
this.canvas.width = width;
|
|
4400
4414
|
this.canvas.height = height;
|
|
4415
|
+
this.cachedImageData = this.ctx.createImageData(width, height);
|
|
4416
|
+
this.cachedWidth = width;
|
|
4417
|
+
this.cachedHeight = height;
|
|
4401
4418
|
}
|
|
4402
|
-
const imageData =
|
|
4419
|
+
const imageData = this.cachedImageData;
|
|
4420
|
+
const dest = imageData.data;
|
|
4421
|
+
dest.set(data);
|
|
4403
4422
|
this.ctx.putImageData(imageData, 0, 0);
|
|
4404
4423
|
}
|
|
4405
4424
|
updateFps() {
|
|
@@ -4457,6 +4476,10 @@ class EcPlayerCore {
|
|
|
4457
4476
|
this.player.load(url),
|
|
4458
4477
|
this.player.preInitDecoder()
|
|
4459
4478
|
]);
|
|
4479
|
+
if (!this.player) {
|
|
4480
|
+
console.log("[EcPlayerCore] Player destroyed during load, aborting");
|
|
4481
|
+
return;
|
|
4482
|
+
}
|
|
4460
4483
|
if (this.player instanceof HLSPlayer) {
|
|
4461
4484
|
this.detectedFormat = this.player.isFMP4 ? "hls-fmp4" : "hls-ts";
|
|
4462
4485
|
console.log("[EcPlayerCore] Updated format after playlist parse:", this.detectedFormat);
|
|
@@ -4808,12 +4831,12 @@ const _EnvDetector = class _EnvDetector {
|
|
|
4808
4831
|
// function index: 0
|
|
4809
4832
|
// Code section (10)
|
|
4810
4833
|
10,
|
|
4811
|
-
|
|
4834
|
+
23,
|
|
4812
4835
|
1,
|
|
4813
|
-
// section id=10, size=
|
|
4814
|
-
|
|
4836
|
+
// section id=10, size=23, 1 func
|
|
4837
|
+
21,
|
|
4815
4838
|
0,
|
|
4816
|
-
// func body size=
|
|
4839
|
+
// func body size=21, 0 locals
|
|
4817
4840
|
// v128.const i32x4 0 0 0 0
|
|
4818
4841
|
253,
|
|
4819
4842
|
12,
|