From b67bd9a2bac6ce245efe5b8ce83ad9c5d7363705 Mon Sep 17 00:00:00 2001 From: Vinlic Date: Fri, 17 Nov 2023 00:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=9D=97=E8=A7=86=E9=A2=91=E9=9F=B3?= =?UTF-8?q?=E9=A2=91=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4=E7=82=B9=E6=9C=AA?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=97=B6=E8=87=AA=E5=8A=A8=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=B8=BA=E5=88=86=E5=9D=97=E6=97=B6=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/ChunkSynthesizer.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/ChunkSynthesizer.js b/core/ChunkSynthesizer.js index c675624..8bb0cd7 100644 --- a/core/ChunkSynthesizer.js +++ b/core/ChunkSynthesizer.js @@ -98,10 +98,12 @@ export default class ChunkSynthesizer extends Synthesizer { const chunksRenderPromises = []; this.chunks.forEach(chunk => { chunk.audios.forEach(audio => { - if (_.isFinite(audio.startTime)) - audio.startTime += offsetTime; - if (_.isFinite(audio.endTime)) - audio.endTime += offsetTime; + if (!_.isFinite(audio.startTime)) + audio.startTime = 0; + audio.startTime += offsetTime; + if (!_.isFinite(audio.endTime)) + audio.endTime = chunk.duration; + audio.endTime += offsetTime; this.addAudio(audio); }); // 分块未完成时先进行渲染 @@ -126,7 +128,11 @@ export default class ChunkSynthesizer extends Synthesizer { return await new Promise((resolve, reject) => { chunk.on("audioAdd", options => { const audio = this.addAudio(options); + if (!_.isFinite(audio.startTime)) + audio.startTime = 0; audio.startTime += offsetTime; + if (!_.isFinite(audio.endTime)) + audio.endTime = chunk.duration; audio.endTime += offsetTime; }); chunk.on("audioUpdate", options => {