diff --git a/package.json b/package.json index 689a02e..efcc0b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "6.4.124", + "version": "6.4.125", "license": "BUSL-1.1", "private": true, "packageManager": "pnpm@9.15.5", diff --git a/src/lib/components/SearchModal.svelte b/src/lib/components/SearchModal.svelte index 93e8a3a..aa1a8c0 100644 --- a/src/lib/components/SearchModal.svelte +++ b/src/lib/components/SearchModal.svelte @@ -184,7 +184,7 @@
diff --git a/src/lib/components/ui/button/progress-button.svelte b/src/lib/components/ui/button/progress-button.svelte index c59cd5c..460cbbb 100644 --- a/src/lib/components/ui/button/progress-button.svelte +++ b/src/lib/components/ui/button/progress-button.svelte @@ -36,8 +36,8 @@ = [ - ['Opening', /^op$|opening$|^ncop|^opening /mi], - ['Ending', /^ed$|ending$|^nced|^ending /mi], - ['Recap', /recap/mi] - ] - function isChapterSkippable (chapter: Chapter) { - for (const [name, regex] of skippableChaptersRx) { - if (regex.test(chapter.text)) { - return name - } - } - return null + function stopAnimation () { + animating = false } - function findChapter (time: number) { - return chapters.find(({ start, end }) => time >= start && time <= end) - } + let animating = false function skip () { - const current = findChapter(currentTime) + const current = findChapter(currentTime, chapters) if (current) { if (!isChapterSkippable(current) && (current.end - current.start) > 100) { currentTime = currentTime + 85 } else { const endtime = current.end - if ((safeduration - endtime | 0) === 0) return next?.() currentTime = endtime currentSkippable = null } @@ -360,7 +349,6 @@ } else { currentTime = currentTime + 85 } - video.currentTime = currentTime } let stats: { @@ -742,7 +730,7 @@ -
resetMove(2000)} on:wheel={handleWheel}> +
resetMove(2000)} on:wheel={handleWheel} on:keydown={stopAnimation} on:focusin={stopAnimation} on:pointerenter={stopAnimation} on:pointermove={stopAnimation}>
+ {#if currentSkippable} + + Skip {currentSkippable} + + {/if}
- {#if currentSkippable} - - {/if}
{getChapterTitle(seeking ? seekPercent * safeduration / 100 : currentTime, chapters) || ''}
{toTS(seeking ? seekPercent * safeduration / 100 : currentTime)} / {toTS(safeduration)}
diff --git a/src/lib/components/ui/player/util.ts b/src/lib/components/ui/player/util.ts index 66dfe54..1a9ea26 100644 --- a/src/lib/components/ui/player/util.ts +++ b/src/lib/components/ui/player/util.ts @@ -194,7 +194,21 @@ export async function screenshot (video: HTMLVideoElement, subtitles?: Subtitles const blob = await new Promise(resolve => canvas.toBlob(b => resolve(b!))) canvas.remove() await navigator.clipboard.write([new ClipboardItem({ [blob.type]: blob })]) - toast.success('Screenshot', { - description: 'Saved screenshot to clipboard.' - }) + toast.success('Screenshot', { description: 'Saved screenshot to clipboard.' }) +} + +const skippableChaptersRx: Array<[string, RegExp]> = [ + ['Opening', /^op$|opening$|^ncop|^opening /mi], + ['Ending', /^ed$|ending$|^nced|^ending /mi], + ['Recap', /recap/mi] +] +export function isChapterSkippable ({ text }: Chapter) { + for (const [name, regex] of skippableChaptersRx) { + if (regex.test(text)) return name + } + return null +} + +export function findChapter (time: number, chapters: Chapter[]) { + return chapters.find(({ start, end }) => time >= start && time <= end) }