Sync shared snapshot from db14c02
Docker / Docker Build & Push (push) Successful in 3m44s

This commit is contained in:
Gabriel20xx committed 2026-09-25 11:28:50 +02:00
1 parent efda65ae5f
commit be0d4a87f5
2 files changed
+210 -59

No files matched your search

@@ -15,9 +15,11 @@
autoplay = false, autoplay = false,
class: className = '', class: className = '',
mediaClass = '', mediaClass = '',
showSeekButtons = true, showSeekButtons: _showSeekButtons = true,
showVolume = true, showVolume = true,
showFullscreen = true, showFullscreen = true,
showGraph = false,
graphVisible = false,
qualityOptions = [], qualityOptions = [],
selectedQuality = '', selectedQuality = '',
currentTime: externalCurrentTime = null, currentTime: externalCurrentTime = null,
@@ -30,6 +32,8 @@
onEnded, onEnded,
onSeek, onSeek,
onSkip, onSkip,
onQualityChange,
onToggleGraph,
endControls, endControls,
}: { }: {
kind?: MediaPlayerKind kind?: MediaPlayerKind
@@ -39,9 +43,12 @@
autoplay?: boolean autoplay?: boolean
class?: string class?: string
mediaClass?: string mediaClass?: string
/** @deprecated Seeking is available with the arrow keys and mobile double-tap. */
showSeekButtons?: boolean showSeekButtons?: boolean
showVolume?: boolean showVolume?: boolean
showFullscreen?: boolean showFullscreen?: boolean
showGraph?: boolean
graphVisible?: boolean
qualityOptions?: MediaPlayerQualityOption[] qualityOptions?: MediaPlayerQualityOption[]
selectedQuality?: string selectedQuality?: string
currentTime?: number | null currentTime?: number | null
@@ -54,6 +61,8 @@
onEnded?: (event: Event) => void onEnded?: (event: Event) => void
onSeek?: (value: number) => void onSeek?: (value: number) => void
onSkip?: (seconds: number) => void onSkip?: (seconds: number) => void
onQualityChange?: (value: string) => void
onToggleGraph?: () => void
endControls?: Snippet endControls?: Snippet
} = $props() } = $props()
@@ -66,7 +75,9 @@
let muted = $state(false) let muted = $state(false)
let fullscreen = $state(false) let fullscreen = $state(false)
let controlsVisible = $state(true) let controlsVisible = $state(true)
let orientationLocked = $state(false)
let controlsHideTimeout: ReturnType<typeof setTimeout> | null = null let controlsHideTimeout: ReturnType<typeof setTimeout> | null = null
let orientationLockRequest = 0
const currentTime = $derived(externalCurrentTime ?? internalTime) const currentTime = $derived(externalCurrentTime ?? internalTime)
const duration = $derived(externalDuration ?? internalDuration) const duration = $derived(externalDuration ?? internalDuration)
@@ -127,6 +138,60 @@
} }
} }
function isMobileDevice() {
return (
typeof window !== 'undefined' &&
(window.matchMedia?.('(pointer: coarse)').matches === true || navigator.maxTouchPoints > 0)
)
}
function isWideVideo() {
return Boolean(
mediaElement &&
!audio &&
mediaElement instanceof HTMLVideoElement &&
mediaElement.videoWidth > mediaElement.videoHeight,
)
}
async function syncScreenOrientation(nextFullscreen: boolean) {
const request = ++orientationLockRequest
const orientation =
typeof window !== 'undefined'
? (window.screen?.orientation as
| (ScreenOrientation & {
lock: (orientation: 'landscape') => Promise<void>
})
| undefined)
: undefined
const shouldLock = nextFullscreen && isMobileDevice() && isWideVideo()
if (!shouldLock) {
if (orientationLocked) orientation?.unlock()
orientationLocked = false
return
}
if (!orientation?.lock) return
try {
await orientation.lock('landscape')
if (request !== orientationLockRequest) {
orientation.unlock()
return
}
orientationLocked = true
} catch {
// Orientation locking is not available in every mobile browser.
}
}
function handleVideoDoubleTap(event: MouseEvent) {
if (audio || !isMobileDevice()) return
const target = event.currentTarget as HTMLVideoElement
const bounds = target.getBoundingClientRect()
skip(event.clientX - bounds.left < bounds.width / 2 ? -10 : 10)
}
function handlePlay(event: Event) { function handlePlay(event: Event) {
playing = true playing = true
onPlay?.(event) onPlay?.(event)
@@ -148,6 +213,7 @@
internalDuration = Number.isFinite(mediaElement.duration) ? mediaElement.duration : 0 internalDuration = Number.isFinite(mediaElement.duration) ? mediaElement.duration : 0
volume = mediaElement.volume volume = mediaElement.volume
muted = mediaElement.muted || mediaElement.volume === 0 muted = mediaElement.muted || mediaElement.volume === 0
void syncScreenOrientation(fullscreen)
onLoadedMetadata?.(event) onLoadedMetadata?.(event)
} }
@@ -219,6 +285,7 @@
function handleFullscreenChange() { function handleFullscreenChange() {
fullscreen = Boolean(document.fullscreenElement) fullscreen = Boolean(document.fullscreenElement)
void syncScreenOrientation(fullscreen)
} }
$effect(() => { $effect(() => {
@@ -247,16 +314,18 @@
return () => { return () => {
for (const eventName of activityEvents) playerFrame?.removeEventListener(eventName, handlePlayerActivity) for (const eventName of activityEvents) playerFrame?.removeEventListener(eventName, handlePlayerActivity)
orientationLockRequest += 1
if (orientationLocked) {
window.screen?.orientation?.unlock()
orientationLocked = false
}
} }
}) })
</script> </script>
<svelte:window onfullscreenchange={handleFullscreenChange} /> <svelte:window onfullscreenchange={handleFullscreenChange} />
<div <div bind:this={playerFrame} class={`media-player ${className}`}>
bind:this={playerFrame}
class={`media-player ${className}`}
>
{#if audio} {#if audio}
<div <div
class="media-player-audio-surface" class="media-player-audio-surface"
@@ -294,9 +363,11 @@
{autoplay} {autoplay}
preload="auto" preload="auto"
playsinline playsinline
tabindex="0"
class={`media-player-video ${mediaClass}`} class={`media-player-video ${mediaClass}`}
aria-label={title ? `Video player for ${title}` : 'Video player'} aria-label={title ? `Video player for ${title}` : 'Video player'}
onclick={handleSurfaceClick} onclick={handleSurfaceClick}
ondblclick={handleVideoDoubleTap}
onkeydown={handleKeydown} onkeydown={handleKeydown}
onplay={handlePlay} onplay={handlePlay}
onpause={handlePause} onpause={handlePause}
@@ -320,15 +391,17 @@
{controlsVisible} {controlsVisible}
onTogglePlayback={togglePlayback} onTogglePlayback={togglePlayback}
onSeek={seek} onSeek={seek}
onSkip={skip}
onToggleMute={toggleMute} onToggleMute={toggleMute}
onVolumeChange={changeVolume} onVolumeChange={changeVolume}
onToggleFullscreen={toggleFullscreen} onToggleFullscreen={toggleFullscreen}
{showSeekButtons}
{showVolume} {showVolume}
{showFullscreen} {showFullscreen}
{showGraph}
{graphVisible}
{qualityOptions} {qualityOptions}
{selectedQuality} {selectedQuality}
{onQualityChange}
{onToggleGraph}
{endControls} {endControls}
overlay overlay
/> />
@@ -357,6 +430,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: contain; object-fit: contain;
touch-action: manipulation;
} }
.media-player-audio-surface { .media-player-audio-surface {
@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Activity, Maximize2, Minimize2, Pause, Play, RotateCcw, RotateCw, Volume2, VolumeX } from '@lucide/svelte' import { Maximize2, Minimize2, Pause, Play, Settings, Volume2, VolumeX } from '@lucide/svelte'
import { onMount } from 'svelte'
import type { Snippet } from 'svelte' import type { Snippet } from 'svelte'
export type MediaPlayerKind = 'audio' | 'video' export type MediaPlayerKind = 'audio' | 'video'
@@ -20,7 +21,7 @@
disabled = false, disabled = false,
overlay = false, overlay = false,
controlsVisible = true, controlsVisible = true,
showSeekButtons = true, showSeekButtons: _showSeekButtons = true,
showVolume = true, showVolume = true,
showFullscreen = true, showFullscreen = true,
showGraph = false, showGraph = false,
@@ -29,7 +30,7 @@
selectedQuality = '', selectedQuality = '',
onTogglePlayback, onTogglePlayback,
onSeek, onSeek,
onSkip, onSkip: _onSkip,
onToggleMute, onToggleMute,
onVolumeChange, onVolumeChange,
onToggleFullscreen, onToggleFullscreen,
@@ -47,6 +48,7 @@
disabled?: boolean disabled?: boolean
overlay?: boolean overlay?: boolean
controlsVisible?: boolean controlsVisible?: boolean
/** @deprecated Seeking is available with the arrow keys and mobile double-tap. */
showSeekButtons?: boolean showSeekButtons?: boolean
showVolume?: boolean showVolume?: boolean
showFullscreen?: boolean showFullscreen?: boolean
@@ -56,6 +58,7 @@
selectedQuality?: string selectedQuality?: string
onTogglePlayback?: () => void onTogglePlayback?: () => void
onSeek?: (value: number) => void onSeek?: (value: number) => void
/** @deprecated Seeking is handled by the player surface. */
onSkip?: (seconds: number) => void onSkip?: (seconds: number) => void
onToggleMute?: () => void onToggleMute?: () => void
onVolumeChange?: (value: number) => void onVolumeChange?: (value: number) => void
@@ -65,6 +68,9 @@
endControls?: Snippet endControls?: Snippet
} = $props() } = $props()
let settingsMenu = $state<HTMLDivElement | null>(null)
let settingsOpen = $state(false)
const progress = $derived(duration > 0 ? `${Math.min(100, Math.max(0, (currentTime / duration) * 100))}%` : '0%') const progress = $derived(duration > 0 ? `${Math.min(100, Math.max(0, (currentTime / duration) * 100))}%` : '0%')
const displayVolume = $derived(muted ? 0 : Math.min(1, Math.max(0, volume))) const displayVolume = $derived(muted ? 0 : Math.min(1, Math.max(0, volume)))
const label = $derived(kind === 'audio' ? 'audio' : 'video') const label = $derived(kind === 'audio' ? 'audio' : 'video')
@@ -88,11 +94,31 @@
function handleQuality(event: Event) { function handleQuality(event: Event) {
onQualityChange?.((event.currentTarget as HTMLSelectElement).value) onQualityChange?.((event.currentTarget as HTMLSelectElement).value)
settingsOpen = false
} }
function handleDocumentPointerDown(event: PointerEvent) {
if (settingsOpen && !settingsMenu?.contains(event.target as Node)) settingsOpen = false
}
function handleDocumentKeydown(event: KeyboardEvent) {
if (event.key === 'Escape') settingsOpen = false
}
onMount(() => {
document.addEventListener('pointerdown', handleDocumentPointerDown)
document.addEventListener('keydown', handleDocumentKeydown)
return () => {
document.removeEventListener('pointerdown', handleDocumentPointerDown)
document.removeEventListener('keydown', handleDocumentKeydown)
}
})
</script> </script>
<div <div
class:media-player-controls-overlay={overlay} class:media-player-controls-overlay={overlay}
class:media-player-controls-fullscreen={fullscreen}
class:media-player-controls-hidden={!controlsVisible} class:media-player-controls-hidden={!controlsVisible}
class="media-player-controls" class="media-player-controls"
> >
@@ -120,26 +146,6 @@
> >
{#if playing}<Pause class="media-player-icon-large" />{:else}<Play class="media-player-icon-large" />{/if} {#if playing}<Pause class="media-player-icon-large" />{:else}<Play class="media-player-icon-large" />{/if}
</button> </button>
{#if showSeekButtons}
<button
type="button"
class="media-player-control media-player-seek-button"
aria-label="Rewind 10 seconds"
title="Rewind 10 seconds (Left Arrow)"
{disabled}
onclick={() => onSkip?.(-10)}><RotateCcw class="media-player-icon" /></button
>
<button
type="button"
class="media-player-control media-player-seek-button"
aria-label="Skip forward 10 seconds"
title="Skip forward 10 seconds (Right Arrow)"
{disabled}
onclick={() => onSkip?.(10)}><RotateCw class="media-player-icon" /></button
>
{/if}
<span class="media-player-time">{formatTime(currentTime)} / {formatTime(duration)}</span>
<div class="media-player-control-trailing">
{#if showVolume} {#if showVolume}
<button <button
type="button" type="button"
@@ -164,31 +170,51 @@
oninput={handleVolume} oninput={handleVolume}
/> />
{/if} {/if}
{#if qualityOptions.length > 0} <span class="media-player-time">{formatTime(currentTime)} / {formatTime(duration)}</span>
<select <div class="media-player-control-trailing">
class="media-player-quality" {@render endControls?.()}
value={selectedQuality} {#if showGraph || qualityOptions.length > 0}
aria-label="Video quality" <div bind:this={settingsMenu} class="media-player-settings">
title="Video quality" <button
type="button"
class="media-player-control"
aria-label="Player settings"
aria-expanded={settingsOpen}
aria-haspopup="dialog"
title="Player settings"
{disabled} {disabled}
onchange={handleQuality} onclick={() => (settingsOpen = !settingsOpen)}
> >
<Settings class="media-player-icon" />
</button>
{#if settingsOpen}
<div class="media-player-settings-menu" role="dialog" aria-label="Player settings">
{#if showGraph}
<button
type="button"
class="media-player-settings-toggle"
role="switch"
aria-checked={graphVisible}
{disabled}
onclick={onToggleGraph}
>
<span>Funscript graph</span>
<span class="media-player-settings-status">{graphVisible ? 'On' : 'Off'}</span>
</button>
{/if}
{#if qualityOptions.length > 0}
<label class="media-player-settings-quality">
<span>Quality</span>
<select value={selectedQuality} aria-label="Video quality" {disabled} onchange={handleQuality}>
{#each qualityOptions as option (option.value)} {#each qualityOptions as option (option.value)}
<option value={option.value}>{option.label}</option> <option value={option.value}>{option.label}</option>
{/each} {/each}
</select> </select>
</label>
{/if} {/if}
{@render endControls?.()} </div>
{#if showGraph} {/if}
<button </div>
type="button"
class="media-player-control"
aria-label={graphVisible ? 'Hide funscript graph' : 'Show funscript graph'}
aria-pressed={graphVisible}
title={graphVisible ? 'Hide funscript graph' : 'Show funscript graph'}
{disabled}
onclick={onToggleGraph}><Activity class="media-player-icon" /></button
>
{/if} {/if}
{#if showFullscreen} {#if showFullscreen}
<button <button
@@ -375,20 +401,67 @@
white-space: nowrap; white-space: nowrap;
} }
.media-player-quality { .media-player-settings {
width: auto; position: relative;
max-width: 6.25rem; }
height: 2.25rem;
.media-player-settings-menu {
position: absolute;
right: 0;
bottom: calc(100% + 0.5rem);
z-index: 30;
display: grid;
min-width: 13rem;
gap: 0.25rem;
padding: 0.4rem;
border: 1px solid rgb(255 255 255 / 0.18); border: 1px solid rgb(255 255 255 / 0.18);
border-radius: 0.5rem; border-radius: 0.6rem;
background: rgb(0 0 0 / 0.42); background: rgb(16 18 23 / 0.96);
padding: 0 0.5rem; box-shadow: 0 0.5rem 1.5rem rgb(0 0 0 / 0.35);
color: rgb(255 255 255 / 0.92); color: white;
}
.media-player-settings-toggle,
.media-player-settings-quality {
display: flex;
width: 100%;
min-height: 2.25rem;
align-items: center;
justify-content: space-between;
gap: 1rem;
border-radius: 0.4rem;
padding: 0.35rem 0.5rem;
color: rgb(255 255 255 / 0.9);
font-size: 0.75rem; font-size: 0.75rem;
text-align: left;
}
.media-player-settings-toggle {
border: 0;
background: transparent;
cursor: pointer; cursor: pointer;
} }
.media-player-quality option { .media-player-settings-toggle:hover:not(:disabled) {
background: rgb(255 255 255 / 0.12);
}
.media-player-settings-status {
color: var(--sc-primary, #80b6f5);
font-weight: 600;
}
.media-player-settings-quality select {
max-width: 7rem;
border: 1px solid rgb(255 255 255 / 0.18);
border-radius: 0.35rem;
background: rgb(0 0 0 / 0.42);
padding: 0.25rem 0.35rem;
color: inherit;
font-size: inherit;
}
.media-player-settings-quality option {
background: var(--sc-surface, #1b1f27); background: var(--sc-surface, #1b1f27);
color: var(--sc-fg, white); color: var(--sc-fg, white);
} }
@@ -396,7 +469,8 @@
.media-player-control:focus-visible, .media-player-control:focus-visible,
.media-player-progress:focus-visible, .media-player-progress:focus-visible,
.media-player-volume:focus-visible, .media-player-volume:focus-visible,
.media-player-quality:focus-visible { .media-player-settings-toggle:focus-visible,
.media-player-settings-quality select:focus-visible {
outline: 2px solid var(--sc-ring, var(--sc-primary, #80b6f5)); outline: 2px solid var(--sc-ring, var(--sc-primary, #80b6f5));
outline-offset: 2px; outline-offset: 2px;
} }
@@ -412,9 +486,12 @@
} }
@media (max-width: 639px) { @media (max-width: 639px) {
.media-player-seek-button,
.media-player-volume { .media-player-volume {
display: none; display: none;
} }
.media-player-controls-fullscreen .media-player-volume {
display: block;
}
} }
</style> </style>