mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2024-11-10 09:07:45 +01:00
Use fast time to decimal for non display calculations
This commit is contained in:
parent
41a25720d0
commit
cf0e91c4ff
1 changed files with 10 additions and 2 deletions
|
@ -531,7 +531,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.intervalToDecimal(lastTime, nextTime) > MIN_CHAPTER_SIZE) {
|
||||
if (this.fastIntervalToDecimal(lastTime, nextTime) > MIN_CHAPTER_SIZE) {
|
||||
result.push({
|
||||
segment: [lastTime, nextTime],
|
||||
originalDuration: 0,
|
||||
|
@ -866,7 +866,7 @@ class PreviewBar {
|
|||
}
|
||||
|
||||
private chapterGroupFilter(segment: SegmentContainer): boolean {
|
||||
return segment.segment.length === 2 && this.intervalToDecimal(segment.segment[0], segment.segment[1]) > MIN_CHAPTER_SIZE;
|
||||
return segment.segment.length === 2 && this.fastIntervalToDecimal(segment.segment[0], segment.segment[1]) > MIN_CHAPTER_SIZE;
|
||||
}
|
||||
|
||||
intervalToPercentage(startTime: number, endTime: number) {
|
||||
|
@ -877,6 +877,10 @@ 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}%`
|
||||
}
|
||||
|
@ -912,6 +916,10 @@ class PreviewBar {
|
|||
}
|
||||
}
|
||||
|
||||
return this.fastTimeToDecimal(time);
|
||||
}
|
||||
|
||||
fastTimeToDecimal(time: number): number {
|
||||
return Math.min(1, time / this.videoDuration);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue