mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-28 01:28:27 +01:00
Adds dependency-free helpers in utils/chapters.ts for working with Jellyfin chapter markers: - chapterMarkers(chapters, durationMs): markers within range, with precomputed percent for slider overlays. - chapterStartsMs(chapters): sorted start positions in ms (skips entries without StartPositionTicks). - currentChapterIndex(positionMs, chapters): active chapter index for the live playback position (-1 if before the first chapter). - chapterNameAt(positionMs, chapters): the active chapter name, or null if missing/unnamed. - sortedChapters(chapters): chapter entries paired with ms start. - formatChapterTime(positionMs): m:ss or h:mm:ss label. All helpers tolerate null/undefined/empty inputs. 17 unit tests under bun test cover sort order, boundary positions, missing fields, and out-of-range inputs.