mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-08-17 12:48:09 +00:00
fix: thumbnailer not generating images on the go
This commit is contained in:
parent
5de442010b
commit
61688bc2ac
3 changed files with 5 additions and 1 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue