mirror of
https://git.shipoclu.com/moon/plspace.git
synced 2026-08-13 02:42:30 +00:00
preload a little of video to make the video show
This commit is contained in:
@@ -24,6 +24,17 @@
|
||||
function toggle(id: string): void {
|
||||
revealed = { ...revealed, [id]: !revealed[id] }
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the browser to decode the first real frame while it loads metadata.
|
||||
* The tiny media-fragment seek also makes the video's intrinsic dimensions
|
||||
* available before playback on browsers that otherwise leave it at 300×150.
|
||||
*/
|
||||
function videoPreviewUrl(url: string): string {
|
||||
const fragment = url.indexOf('#')
|
||||
const base = fragment >= 0 ? url.slice(0, fragment) : url
|
||||
return `${base}#t=0.001`
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if attachments.length > 0}
|
||||
@@ -39,12 +50,12 @@
|
||||
{#if media.type === 'video' || media.type === 'gifv'}
|
||||
<video
|
||||
class="attachment-media"
|
||||
src={media.url}
|
||||
src={videoPreviewUrl(media.url)}
|
||||
poster={media.preview_url ?? undefined}
|
||||
controls
|
||||
playsinline
|
||||
loop={media.type === 'gifv'}
|
||||
preload="none"
|
||||
preload="metadata"
|
||||
>
|
||||
<!-- Remote media carries no caption track; declared so the
|
||||
requirement is explicit rather than merely unmet. -->
|
||||
|
||||
Reference in New Issue
Block a user