2024-02-02 22:21:48 +08:00
|
|
|
<script context="module">
|
|
|
|
import { Template, Story } from "@storybook/addon-svelte-csf";
|
2023-10-31 12:46:02 +08:00
|
|
|
import Video from "./Index.svelte";
|
2023-11-07 18:58:34 +08:00
|
|
|
import { format } from "svelte-i18n";
|
|
|
|
import { get } from "svelte/store";
|
2023-12-05 05:38:55 +08:00
|
|
|
import { userEvent, within } from "@storybook/testing-library";
|
2024-02-02 22:21:48 +08:00
|
|
|
import { allModes } from "../storybook/modes";
|
2023-08-04 06:01:18 +08:00
|
|
|
|
2024-02-02 22:21:48 +08:00
|
|
|
export const meta = {
|
|
|
|
title: "Components/Video",
|
|
|
|
component: Video,
|
|
|
|
parameters: {
|
|
|
|
chromatic: {
|
|
|
|
modes: {
|
|
|
|
desktop: allModes["desktop"],
|
|
|
|
mobile: allModes["mobile"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
2023-08-04 06:01:18 +08:00
|
|
|
|
2023-11-07 18:58:34 +08:00
|
|
|
<div>
|
|
|
|
<Template let:args>
|
2023-12-05 05:38:55 +08:00
|
|
|
<Video i18n={get(format)} {...args} />
|
2023-11-07 18:58:34 +08:00
|
|
|
</Template>
|
|
|
|
</div>
|
2023-08-04 06:01:18 +08:00
|
|
|
|
|
|
|
<Story
|
2023-11-02 20:10:11 +08:00
|
|
|
name="Record from webcam"
|
2023-08-04 06:01:18 +08:00
|
|
|
args={{
|
|
|
|
format: "mp4",
|
|
|
|
label: "world video",
|
|
|
|
show_label: true,
|
|
|
|
interactive: true,
|
|
|
|
height: 400,
|
|
|
|
width: 400
|
|
|
|
}}
|
|
|
|
/>
|
2023-11-02 20:10:11 +08:00
|
|
|
|
|
|
|
<Story
|
|
|
|
name="Static video"
|
|
|
|
args={{
|
|
|
|
value: {
|
|
|
|
video: {
|
|
|
|
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
|
|
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
|
|
orig_name: "world.mp4"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
label: "world video",
|
|
|
|
show_label: true,
|
2024-01-23 18:33:59 +08:00
|
|
|
show_download_button: true,
|
2023-11-02 20:10:11 +08:00
|
|
|
interactive: false,
|
|
|
|
height: 200,
|
|
|
|
width: 400
|
|
|
|
}}
|
|
|
|
/>
|
2023-12-08 01:19:09 +08:00
|
|
|
<Story
|
|
|
|
name="Static video with vertical video"
|
|
|
|
args={{
|
|
|
|
value: {
|
|
|
|
video: {
|
|
|
|
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world_vertical.mp4",
|
|
|
|
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world_vertical.mp4",
|
|
|
|
orig_name: "world_vertical.mp4"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
label: "world video",
|
|
|
|
show_label: true,
|
2024-01-23 18:33:59 +08:00
|
|
|
show_download_button: false,
|
2023-12-08 01:19:09 +08:00
|
|
|
interactive: false,
|
|
|
|
height: 200,
|
|
|
|
width: 400
|
|
|
|
}}
|
|
|
|
/>
|
2023-11-07 18:58:34 +08:00
|
|
|
|
|
|
|
<Story
|
|
|
|
name="Upload video"
|
|
|
|
args={{
|
|
|
|
label: "world video",
|
|
|
|
show_label: true,
|
|
|
|
interactive: true,
|
|
|
|
sources: ["upload", "webcam"],
|
|
|
|
width: 400,
|
|
|
|
height: 400,
|
|
|
|
value: null
|
|
|
|
}}
|
|
|
|
/>
|
2023-12-05 05:38:55 +08:00
|
|
|
|
2024-01-23 18:33:59 +08:00
|
|
|
<Story
|
|
|
|
name="Upload video with download button"
|
|
|
|
args={{
|
|
|
|
label: "world video",
|
|
|
|
show_label: true,
|
|
|
|
interactive: true,
|
|
|
|
sources: ["upload", "webcam"],
|
|
|
|
show_download_button: true,
|
|
|
|
width: 400,
|
|
|
|
height: 400,
|
|
|
|
value: {
|
|
|
|
video: {
|
|
|
|
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
|
|
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
|
|
orig_name: "world.mp4"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
2023-12-05 05:38:55 +08:00
|
|
|
<Story
|
|
|
|
name="Trim video"
|
|
|
|
args={{
|
|
|
|
value: {
|
|
|
|
video: {
|
|
|
|
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
|
|
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
|
|
orig_name: "world.mp4"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
label: "world video",
|
|
|
|
show_label: true,
|
|
|
|
interactive: "true",
|
|
|
|
sources: ["upload"],
|
|
|
|
width: 400
|
|
|
|
}}
|
|
|
|
play={async ({ canvasElement }) => {
|
|
|
|
const canvas = within(canvasElement);
|
|
|
|
const trimButton = canvas.getByLabelText("Trim video to selection");
|
|
|
|
userEvent.click(trimButton);
|
|
|
|
}}
|
|
|
|
/>
|