From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001
From: rxliuli <rxliuli@gmail.com>
Date: Tue, 4 Nov 2025 05:03:50 +0800
Subject: init commit

---
 src/components/jet/Video.svelte | 66 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 src/components/jet/Video.svelte

(limited to 'src/components/jet/Video.svelte')

diff --git a/src/components/jet/Video.svelte b/src/components/jet/Video.svelte
new file mode 100644
index 0000000..8d2e4f3
--- /dev/null
+++ b/src/components/jet/Video.svelte
@@ -0,0 +1,66 @@
+<script lang="ts">
+    import type { Video } from '@jet-app/app-store/api/models';
+    import VideoPlayer from '../VideoPlayer.svelte';
+    import HlsJsDecorator from '../decorators/HlsJSDecorator.svelte';
+    import { buildPoster } from '~/utils/video-poster';
+    import { generateUuid } from '@amp/web-apps-utils/src';
+    import type { NamedProfile } from 'src/config/components/artwork';
+    import type { Profile } from '@amp/web-app-components/src/components/Artwork/types';
+    import mediaQueries from '~/utils/media-queries';
+    import { colorAsString } from '~/utils/color';
+
+    export let video: Video;
+    export let autoplay: boolean = false;
+    export let loop: boolean = false;
+    export let muted: boolean = true;
+    export let useControls: boolean = true;
+    export let profile: NamedProfile | Profile;
+    export let autoplayVisibilityThreshold: number = 0;
+    export let videoPlayerRef: InstanceType<typeof VideoPlayer> | null = null;
+    export let shouldSuperimposePosterImage: boolean = false;
+
+    $: poster =
+        video.preview && buildPoster(video.preview, profile, $mediaQueries);
+    $: backgroundColor = video.preview.backgroundColor
+        ? colorAsString(video.preview.backgroundColor)
+        : '#f1f1f1';
+
+    $: metricsTemplate = video?.templateMediaEvent ?? {};
+    const uuid = generateUuid();
+</script>
+
+<HlsJsDecorator let:HLS>
+    <VideoPlayer
+        {HLS}
+        {loop}
+        {muted}
+        {autoplay}
+        {useControls}
+        {autoplayVisibilityThreshold}
+        {metricsTemplate}
+        {shouldSuperimposePosterImage}
+        id={uuid}
+        src={video.videoUrl}
+        poster={poster ?? undefined}
+        --aspect-ratio={video.preview.width / video.preview.height}
+        bind:this={videoPlayerRef}
+    />
+
+    <div
+        class="loader"
+        slot="loading-component"
+        style:--aspect-ratio={video.preview.width / video.preview.height}
+        style:--background-image={`url(${poster})`}
+        style:--background-color={backgroundColor}
+    />
+</HlsJsDecorator>
+
+<style>
+    .loader {
+        aspect-ratio: var(--aspect-ratio);
+        width: 100%;
+        background-image: var(--background-image);
+        background-color: var(--background-color);
+        background-size: cover;
+    }
+</style>
-- 
cgit v1.2.3

