Reverse fast interval to decimal

It doesn't work when there are imported chapters closely or identical to existing chapters. Causes bar to extend too far.
This commit is contained in:
Ajay
2022-12-11 16:24:53 -05:00
parent 3b776991a6
commit 16581d39a4

View File

@@ -541,7 +541,7 @@ class PreviewBar {
const nextSegment = segments[index + 1];
const nextTime = nextSegment ? nextSegment.segment[0] : this.videoDuration;
const lastTime = result[result.length - 1]?.segment[1] || segment.segment[1];
if (this.fastIntervalToDecimal(lastTime, nextTime) > MIN_CHAPTER_SIZE) {
if (this.intervalToDecimal(lastTime, nextTime) > MIN_CHAPTER_SIZE) {
result.push({
segment: [lastTime, nextTime],
originalDuration: 0,
@@ -876,7 +876,7 @@ class PreviewBar {
}
private chapterGroupFilter(segment: SegmentContainer): boolean {
return segment.segment.length === 2 && this.fastIntervalToDecimal(segment.segment[0], segment.segment[1]) > MIN_CHAPTER_SIZE;
return segment.segment.length === 2 && this.intervalToDecimal(segment.segment[0], segment.segment[1]) > MIN_CHAPTER_SIZE;
}
intervalToPercentage(startTime: number, endTime: number) {
@@ -887,10 +887,6 @@ class PreviewBar {
return (this.timeToDecimal(endTime) - this.timeToDecimal(startTime));
}
fastIntervalToDecimal(startTime: number, endTime: number) {
return (this.fastTimeToDecimal(endTime) - this.fastTimeToDecimal(startTime));
}
timeToPercentage(time: number): string {
return `${this.timeToDecimal(time) * 100}%`
}
@@ -926,10 +922,6 @@ class PreviewBar {
}
}
return this.fastTimeToDecimal(time);
}
fastTimeToDecimal(time: number): number {
return Math.min(1, time / this.videoDuration);
}