make skip to next chapter go to next endpoint and fix reskip stackoverflow

This commit is contained in:
Ajay 2022-07-10 21:51:56 -04:00
parent b1ef8a5d47
commit fdbcf47149

View file

@ -605,6 +605,8 @@ function startSponsorSchedule(includeIntersectingSegments = false, currentTime?:
} else {
forcedSkipTime = forceVideoTime + 0.001;
}
} else {
forcedSkipTime = forceVideoTime + 0.001;
}
startSponsorSchedule(forcedIncludeIntersectingSegments, forcedSkipTime, forcedIncludeNonIntersectingSegments);
@ -2082,13 +2084,14 @@ function updateActiveSegment(currentTime: number): void {
}
function nextChapter(): void {
const chapters = sponsorTimes.filter((time) => time.actionType === ActionType.Chapter);
const chapters = sponsorTimes.filter((time) => time.actionType === ActionType.Chapter)
.sort((a, b) => a.segment[1] - b.segment[1]);
if (chapters.length <= 0) return;
const nextChapter = chapters.findIndex((time) => time.actionType === ActionType.Chapter
&& time.segment[0] > video.currentTime);
&& time.segment[1] > video.currentTime);
if (nextChapter !== -1) {
unskipSponsorTime(chapters[nextChapter], null, true);
reskipSponsorTime(chapters[nextChapter], true);
} else {
video.currentTime = video.duration;
}