2022-02-07 22:34:53 +08:00
|
|
|
<script lang="ts">
|
2023-10-31 12:46:02 +08:00
|
|
|
import Video from "./shared/Video.svelte";
|
|
|
|
import { playable } from "./shared/utils";
|
2024-01-11 08:35:25 +08:00
|
|
|
import { type FileData } from "@gradio/client";
|
2022-02-01 21:45:55 +08:00
|
|
|
|
2023-01-18 04:47:40 +08:00
|
|
|
export let type: "gallery" | "table";
|
|
|
|
export let selected = false;
|
2024-01-11 08:35:25 +08:00
|
|
|
export let value: { video: FileData; subtitles: FileData | null } | null;
|
2022-03-25 12:00:30 +08:00
|
|
|
export let samples_dir: string;
|
2022-02-07 22:34:53 +08:00
|
|
|
let video: HTMLVideoElement;
|
2022-05-25 04:08:08 +08:00
|
|
|
|
2023-02-04 01:36:31 +08:00
|
|
|
async function init(): Promise<void> {
|
2022-05-25 04:08:08 +08:00
|
|
|
video.muted = true;
|
|
|
|
video.playsInline = true;
|
|
|
|
video.controls = false;
|
|
|
|
video.setAttribute("muted", "");
|
2023-02-04 01:36:31 +08:00
|
|
|
|
|
|
|
await video.play();
|
2022-05-25 04:08:08 +08:00
|
|
|
video.pause();
|
2023-02-04 01:36:31 +08:00
|
|
|
}
|
2022-02-01 21:45:55 +08:00
|
|
|
</script>
|
|
|
|
|
2022-07-22 02:12:46 +08:00
|
|
|
{#if playable()}
|
2023-10-17 00:26:49 +08:00
|
|
|
<div
|
|
|
|
class="container"
|
2023-01-18 04:47:40 +08:00
|
|
|
class:table={type === "table"}
|
|
|
|
class:gallery={type === "gallery"}
|
|
|
|
class:selected
|
2023-10-17 00:26:49 +08:00
|
|
|
>
|
|
|
|
<Video
|
|
|
|
muted
|
|
|
|
playsinline
|
|
|
|
bind:node={video}
|
|
|
|
on:loadeddata={init}
|
|
|
|
on:mouseover={video.play.bind(video)}
|
|
|
|
on:mouseout={video.pause.bind(video)}
|
2024-01-11 08:35:25 +08:00
|
|
|
src={samples_dir + value?.video.path}
|
2023-10-17 00:26:49 +08:00
|
|
|
/>
|
|
|
|
</div>
|
2022-02-01 21:45:55 +08:00
|
|
|
{:else}
|
2023-01-18 04:47:40 +08:00
|
|
|
<div>{value}</div>
|
2022-02-01 21:45:55 +08:00
|
|
|
{/if}
|
2023-01-18 04:47:40 +08:00
|
|
|
|
|
|
|
<style>
|
2023-10-17 00:26:49 +08:00
|
|
|
.container {
|
2023-01-18 04:47:40 +08:00
|
|
|
flex: none;
|
|
|
|
max-width: none;
|
|
|
|
}
|
2023-12-12 06:15:02 +08:00
|
|
|
.container :global(video) {
|
|
|
|
width: var(--size-full);
|
|
|
|
height: var(--size-full);
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
2023-01-18 04:47:40 +08:00
|
|
|
|
2023-10-17 00:26:49 +08:00
|
|
|
.container:hover,
|
|
|
|
.container.selected {
|
2023-03-17 22:41:53 +08:00
|
|
|
border-color: var(--border-color-accent);
|
2023-01-18 04:47:40 +08:00
|
|
|
}
|
2023-10-17 00:26:49 +08:00
|
|
|
.container.table {
|
2023-03-07 04:52:31 +08:00
|
|
|
margin: 0 auto;
|
2023-12-12 06:15:02 +08:00
|
|
|
border: 2px solid var(--border-color-primary);
|
|
|
|
border-radius: var(--radius-lg);
|
|
|
|
overflow: hidden;
|
2023-01-18 04:47:40 +08:00
|
|
|
width: var(--size-20);
|
|
|
|
height: var(--size-20);
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
|
2023-10-17 00:26:49 +08:00
|
|
|
.container.gallery {
|
|
|
|
height: var(--size-20);
|
2023-01-18 04:47:40 +08:00
|
|
|
max-height: var(--size-20);
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
</style>
|