fix: thumbnailer not generating images on the go

This commit is contained in:
ThaUnknown 2025-04-25 03:09:20 +02:00
parent 5de442010b
commit 61688bc2ac
No known key found for this signature in database
3 changed files with 5 additions and 1 deletions

View file

@ -24,7 +24,7 @@
{#if $bannerSrc}
<div class={cn('object-cover w-screen absolute top-0 left-0 h-full overflow-hidden pointer-events-none bg-black banner', className)}>
{#key $bannerSrc}
<Banner media={$bannerSrc} class='min-w-[100vw] w-screen h-[23rem] object-cover {$hideBanner ? 'opacity-35' : 'opacity-100'} transition-opacity duration-500 banner-gr relative' />
<Banner media={$bannerSrc} class='min-w-[100vw] w-screen h-[23rem] object-cover {$hideBanner ? 'opacity-10' : 'opacity-100'} transition-opacity duration-500 banner-gr relative' />
{/key}
</div>
{/if}

View file

@ -367,6 +367,9 @@
$: seekIndex = Math.max(0, Math.floor(seekPercent * safeduration / 100 / thumbnailer.interval))
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
$: if (video?.readyState) thumbnailer._paintThumbnail(video, seekIndex)
$: native.setMediaSession(mediaInfo.session)
$: native.setPositionState({ duration: safeduration, position: Math.max(0, currentTime), playbackRate })
$: native.setPlayBackState(readyState === 0 ? 'none' : paused ? 'paused' : 'playing')

View file

@ -78,6 +78,7 @@ export default class Thumbnailer {
// generate and store the thumbnail
async _paintThumbnail (video: HTMLVideoElement, index: number, width = video.videoWidth, height = video.videoHeight) {
if (this.thumbnails[index]) return this.thumbnails[index]
this.canvas.width = this.size
this.canvas.height = height / width * this.size
this.ctx.drawImage(video, 0, 0, this.canvas.width, this.canvas.height)