mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-20 00:02:07 +00:00
feat: autoskip, autopause
This commit is contained in:
parent
14476a19aa
commit
ad4a6f9cbe
3 changed files with 22 additions and 10 deletions
|
|
@ -217,6 +217,21 @@
|
|||
}
|
||||
|
||||
// other
|
||||
$: if (ended && $settings.playerAutoplay) next?.()
|
||||
|
||||
function handleVisibility (visibility: DocumentVisibilityState) {
|
||||
if (!ended && $settings.playerPause && !$pictureInPictureElement) {
|
||||
if (visibility === 'hidden') {
|
||||
visibilityPaused = paused
|
||||
paused = true
|
||||
} else {
|
||||
if (!visibilityPaused) paused = false
|
||||
}
|
||||
}
|
||||
}
|
||||
let visibilityPaused = true
|
||||
let visibilityState: DocumentVisibilityState
|
||||
$: handleVisibility(visibilityState)
|
||||
|
||||
let currentSkippable: string | null = null
|
||||
function checkSkippableChapters () {
|
||||
|
|
@ -225,6 +240,9 @@
|
|||
currentSkippable = isChapterSkippable(current)
|
||||
}
|
||||
}
|
||||
|
||||
$: if (currentSkippable && $settings.playerSkip) skip()
|
||||
|
||||
const skippableChaptersRx: Array<[string, RegExp]> = [
|
||||
['Opening', /^op$|opening$|^ncop/mi],
|
||||
['Ending', /^ed$|ending$|^nced/mi],
|
||||
|
|
@ -508,7 +526,7 @@
|
|||
$: isMiniplayer = $page.route.id !== '/app/player'
|
||||
</script>
|
||||
|
||||
<svelte:document bind:fullscreenElement use:bindPiP={pictureInPictureElement} />
|
||||
<svelte:document bind:fullscreenElement use:bindPiP={pictureInPictureElement} bind:visibilityState />
|
||||
|
||||
<div class='w-full h-full relative content-center fullscreen:bg-black overflow-clip text-left' class:fitWidth bind:this={wrapper}>
|
||||
<video class='w-full h-full grow bg-black' preload='auto' class:cursor-none={immersed} class:cursor-pointer={isMiniplayer} class:object-cover={fitWidth} class:opacity-0={deband} class:absolute={deband} class:top-0={deband}
|
||||
|
|
|
|||
|
|
@ -70,15 +70,6 @@ export default new class LocalSync {
|
|||
// sequelIDs () {
|
||||
// }
|
||||
|
||||
_fillOutKeys (entry: StoredMedia, variables: VariablesOf<typeof Entry>) {
|
||||
const keys = ['status', 'score', 'repeat', 'progress'] as const
|
||||
|
||||
for (const key of keys) {
|
||||
// @ts-expect-error idk how to fix this tbf
|
||||
entry.mediaListEntry[key] = variables[key] ?? null
|
||||
}
|
||||
}
|
||||
|
||||
entry (variables: VariablesOf<typeof Entry>) {
|
||||
this.entries.update(entries => {
|
||||
const entry = this._createEntry(variables.id)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@
|
|||
],
|
||||
"maxNodeModuleJsDepth": 3
|
||||
},
|
||||
"typeAcquisition": {
|
||||
"enable": false
|
||||
},
|
||||
"files": [
|
||||
"src/service-worker/index.ts"
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in a new issue