gradio/js/video/static/StaticVideo.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

95 lines
2.1 KiB
Svelte
Raw Normal View History

<svelte:options accessors={true} />
<script lang="ts">
import { createEventDispatcher } from "svelte";
2022-03-08 21:35:42 +08:00
import type { FileData } from "@gradio/upload";
import { normalise_file } from "@gradio/upload";
import { Block } from "@gradio/atoms";
import StaticVideo from "./VideoPreview.svelte";
import { StatusTracker } from "@gradio/statustracker";
import type { LoadingStatus } from "@gradio/statustracker/types";
2022-03-08 21:35:42 +08:00
import { _ } from "svelte-i18n";
export let elem_id = "";
export let elem_classes: string[] = [];
export let visible = true;
export let value: [FileData, FileData | null] | null = null;
let old_value: [FileData, FileData | null] | null = null;
export let label: string;
export let source: "upload" | "webcam";
export let root: string;
export let root_url: null | string;
export let show_label: boolean;
export let loading_status: LoadingStatus;
export let height: number | undefined;
export let width: number | undefined;
export let container = false;
export let scale: number | null = null;
export let min_width: number | undefined = undefined;
2022-03-12 00:00:48 +08:00
export let mode: "static" | "dynamic";
export let autoplay = false;
export let show_share_button = true;
let _video: FileData | null = null;
let _subtitle: FileData | null = null;
$: {
if (value != null) {
_video = normalise_file(value[0], root, root_url);
_subtitle = normalise_file(value[1], root, root_url);
} else {
_video = null;
_subtitle = null;
}
}
let dragging = false;
const dispatch = createEventDispatcher<{
change: undefined;
}>();
$: {
if (JSON.stringify(value) !== JSON.stringify(old_value)) {
old_value = value;
dispatch("change");
}
}
</script>
<Block
{visible}
variant={mode === "dynamic" && value === null && source === "upload"
? "dashed"
: "solid"}
Python backend to theming (#2931) * add theme + theme atoms * audio * buttons * chatbot * forms * start file * complete file * fixup workbench * gallery * highlighted text * label * json * upload * 3d model * atoms * chart * md + html * image * plot + build * table * tabs * tooltip * upload * tweaks * tweaks + more tooling * tweaks to padding/ lineheight * app components _ start api docs * format, more api docs * finish api docs * interpretation * todos * tweaks + cleanup * tweaks + cleanup * revert range tweaks * fix notebooks * fix test * remove tw * cleanup + login * fix gitignore * fix types * run css script * fix progress + tweaks * update demos * add css build to static check workflow * tweak ci * fix tests * tweak markdown * tweak chatbot + file * fix tabs * tweak tabs * cleanup * fix api docs * fix example gallery * add gradient to toast * fix min height for interfaces * revert tab changes * update notebooks * changes * changes * change * changes * changes * changes * changes * changes * changes * changes * changes * change * changes * changes * changes * changes * changes * changes * changes * fix * changes * changes * changes * changes * changes * changes * undo radius * undo radius * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * changes * change * undo * Add absolute imports * mock theme in tests * clean * changes * changes --------- Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
2023-03-07 04:52:31 +08:00
border_mode={dragging ? "focus" : "base"}
padding={false}
{elem_id}
{elem_classes}
{height}
{width}
{container}
{scale}
{min_width}
allow_overflow={false}
>
<StatusTracker {...loading_status} />
<StaticVideo
value={_video}
subtitle={_subtitle}
{label}
{show_label}
{autoplay}
{show_share_button}
on:play
on:pause
on:stop
on:share
on:error
/>
</Block>