Fix random time calculator for starting empty segment

This commit is contained in:
Ajay 2023-06-08 18:22:26 -04:00
parent fe185234cf
commit 1cacb2dd69

View file

@ -228,13 +228,11 @@ export function findRandomTime(videoID: VideoID, segments: BrandingSegmentDBResu
const emptySegments: [number, number][] = [];
let totalTime = 0;
let nextEndTime = -1;
let nextEndTime = 0;
for (const segment of sorted) {
if (segment.startTime > nextEndTime) {
if (nextEndTime !== -1) {
emptySegments.push([nextEndTime, segment.startTime]);
totalTime += segment.startTime - nextEndTime;
}
emptySegments.push([nextEndTime, segment.startTime]);
totalTime += segment.startTime - nextEndTime;
}
nextEndTime = Math.max(segment.endTime, nextEndTime);