Skip to content

Commit

Permalink
分块视频音频结束时间点未设置时自动设置为分块时长
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinlic committed Nov 16, 2023
1 parent adc5351 commit b67bd9a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/ChunkSynthesizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
// 分块未完成时先进行渲染
Expand All @@ -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 => {
Expand Down

0 comments on commit b67bd9a

Please sign in to comment.