@gradio/video 0.16.0 → 0.17.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/Example.svelte +2 -2
- package/Index.svelte +97 -140
- package/Video.stories.svelte +12 -20
- package/Video.test.ts +22 -50
- package/dist/Example.svelte +21 -17
- package/dist/Example.svelte.d.ts +21 -22
- package/dist/Index.svelte +127 -125
- package/dist/Index.svelte.d.ts +3 -164
- package/dist/shared/InteractiveVideo.svelte +79 -51
- package/dist/shared/InteractiveVideo.svelte.d.ts +57 -47
- package/dist/shared/Player.svelte +103 -71
- package/dist/shared/Player.svelte.d.ts +44 -42
- package/dist/shared/Video.svelte +77 -62
- package/dist/shared/Video.svelte.d.ts +44 -36
- package/dist/shared/VideoControls.svelte +49 -40
- package/dist/shared/VideoControls.svelte.d.ts +29 -27
- package/dist/shared/VideoPreview.svelte +58 -37
- package/dist/shared/VideoPreview.svelte.d.ts +37 -35
- package/dist/shared/VideoTimeline.svelte +148 -106
- package/dist/shared/VideoTimeline.svelte.d.ts +22 -20
- package/dist/shared/types.d.ts +5 -0
- package/dist/shared/types.js +1 -0
- package/dist/types.d.ts +31 -0
- package/dist/types.js +1 -0
- package/package.json +14 -14
- package/shared/InteractiveVideo.svelte +3 -1
- package/shared/Video.svelte +1 -1
- package/shared/types.ts +5 -0
- package/types.ts +37 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @gradio/video
|
|
2
2
|
|
|
3
|
+
## 0.17.0-dev.2
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/atoms@0.19.0-dev.1
|
|
8
|
+
- @gradio/client@2.0.0-dev.2
|
|
9
|
+
- @gradio/statustracker@0.12.0-dev.1
|
|
10
|
+
- @gradio/upload@0.17.2-dev.2
|
|
11
|
+
- @gradio/image@0.24.0-dev.2
|
|
12
|
+
|
|
13
|
+
## 0.17.0-dev.1
|
|
14
|
+
|
|
15
|
+
### Dependency updates
|
|
16
|
+
|
|
17
|
+
- @gradio/atoms@0.18.2-dev.0
|
|
18
|
+
- @gradio/upload@0.17.2-dev.1
|
|
19
|
+
- @gradio/utils@0.10.3-dev.0
|
|
20
|
+
- @gradio/image@0.23.2-dev.1
|
|
21
|
+
- @gradio/statustracker@0.12.0-dev.0
|
|
22
|
+
- @gradio/icons@0.15.0-dev.0
|
|
23
|
+
|
|
24
|
+
## 0.17.0-dev.0
|
|
25
|
+
|
|
26
|
+
### Dependency updates
|
|
27
|
+
|
|
28
|
+
- @gradio/client@2.0.0-dev.1
|
|
29
|
+
|
|
30
|
+
## 0.17.0-dev.0
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
|
|
34
|
+
- [#12041](https://github.com/gradio-app/gradio/pull/12041) [`90e8a2c`](https://github.com/gradio-app/gradio/commit/90e8a2c23774e1d2a7401bccf4bdc86f70531de5) - Video subtitles. Thanks @dawoodkhan82!
|
|
35
|
+
|
|
36
|
+
### Dependency updates
|
|
37
|
+
|
|
38
|
+
- @gradio/upload@0.17.2-dev.0
|
|
39
|
+
- @gradio/client@2.0.0-dev.0
|
|
40
|
+
- @gradio/image@0.23.2-dev.0
|
|
41
|
+
|
|
42
|
+
## 0.16.0
|
|
43
|
+
|
|
44
|
+
### Dependency updates
|
|
45
|
+
|
|
46
|
+
- @gradio/client@1.19.1
|
|
47
|
+
|
|
48
|
+
## 0.16.0
|
|
49
|
+
|
|
50
|
+
### Dependency updates
|
|
51
|
+
|
|
52
|
+
- @gradio/image@0.23.1
|
|
53
|
+
- @gradio/upload@0.17.1
|
|
54
|
+
- @gradio/atoms@0.18.1
|
|
55
|
+
|
|
3
56
|
## 0.16.0
|
|
4
57
|
|
|
5
58
|
### Features
|
package/Example.svelte
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
export let type: "gallery" | "table";
|
|
7
7
|
export let selected = false;
|
|
8
|
-
export let value:
|
|
8
|
+
export let value: null | FileData = null;
|
|
9
9
|
export let loop: boolean;
|
|
10
10
|
let video: HTMLVideoElement;
|
|
11
11
|
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
on:loadeddata={init}
|
|
36
36
|
on:mouseover={video.play.bind(video)}
|
|
37
37
|
on:mouseout={video.pause.bind(video)}
|
|
38
|
-
src={value?.
|
|
38
|
+
src={value?.url}
|
|
39
39
|
is_stream={false}
|
|
40
40
|
{loop}
|
|
41
41
|
/>
|
package/Index.svelte
CHANGED
|
@@ -1,114 +1,60 @@
|
|
|
1
1
|
<svelte:options accessors={true} />
|
|
2
2
|
|
|
3
3
|
<script lang="ts">
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import { tick } from "svelte";
|
|
6
5
|
import type { FileData } from "@gradio/client";
|
|
7
6
|
import { Block, UploadText } from "@gradio/atoms";
|
|
8
7
|
import StaticVideo from "./shared/VideoPreview.svelte";
|
|
9
8
|
import Video from "./shared/InteractiveVideo.svelte";
|
|
10
9
|
import { StatusTracker } from "@gradio/statustracker";
|
|
11
|
-
import
|
|
12
|
-
import type {
|
|
13
|
-
export let elem_id = "";
|
|
14
|
-
export let elem_classes: string[] = [];
|
|
15
|
-
export let visible: boolean | "hidden" = true;
|
|
16
|
-
export let value: { video: FileData; subtitles: FileData | null } | null =
|
|
17
|
-
null;
|
|
18
|
-
let old_value: { video: FileData; subtitles: FileData | null } | null = null;
|
|
19
|
-
|
|
20
|
-
export let label: string;
|
|
21
|
-
export let sources:
|
|
22
|
-
| ["webcam"]
|
|
23
|
-
| ["upload"]
|
|
24
|
-
| ["webcam", "upload"]
|
|
25
|
-
| ["upload", "webcam"];
|
|
26
|
-
export let root: string;
|
|
27
|
-
export let show_label: boolean;
|
|
28
|
-
export let loading_status: LoadingStatus;
|
|
29
|
-
export let height: number | undefined;
|
|
30
|
-
export let width: number | undefined;
|
|
31
|
-
|
|
32
|
-
export let container = false;
|
|
33
|
-
export let scale: number | null = null;
|
|
34
|
-
export let min_width: number | undefined = undefined;
|
|
35
|
-
export let autoplay = false;
|
|
36
|
-
export let show_share_button = true;
|
|
37
|
-
export let show_download_button: boolean;
|
|
38
|
-
export let gradio: Gradio<{
|
|
39
|
-
change: never;
|
|
40
|
-
clear: never;
|
|
41
|
-
play: never;
|
|
42
|
-
pause: never;
|
|
43
|
-
upload: never;
|
|
44
|
-
stop: never;
|
|
45
|
-
end: never;
|
|
46
|
-
start_recording: never;
|
|
47
|
-
stop_recording: never;
|
|
48
|
-
share: ShareData;
|
|
49
|
-
error: string;
|
|
50
|
-
warning: string;
|
|
51
|
-
clear_status: LoadingStatus;
|
|
52
|
-
}>;
|
|
53
|
-
export let interactive: boolean;
|
|
54
|
-
export let webcam_options: WebcamOptions;
|
|
55
|
-
export let include_audio: boolean;
|
|
56
|
-
export let loop = false;
|
|
57
|
-
export let input_ready: boolean;
|
|
58
|
-
let uploading = false;
|
|
59
|
-
$: input_ready = !uploading;
|
|
10
|
+
import { Gradio } from "@gradio/utils";
|
|
11
|
+
import type { VideoProps, VideoEvents } from "./types";
|
|
60
12
|
|
|
61
|
-
|
|
62
|
-
let _subtitle: FileData | null = null;
|
|
13
|
+
const props = $props();
|
|
63
14
|
|
|
64
|
-
let
|
|
15
|
+
let upload_promise = $state<Promise<any>>();
|
|
65
16
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
17
|
+
class VideoGradio extends Gradio<VideoEvents, VideoProps> {
|
|
18
|
+
async get_data() {
|
|
19
|
+
if (upload_promise) {
|
|
20
|
+
await upload_promise;
|
|
21
|
+
await tick();
|
|
22
|
+
}
|
|
23
|
+
const data = await super.get_data();
|
|
72
24
|
|
|
73
|
-
|
|
74
|
-
if (initial_value === null || value === initial_value) {
|
|
75
|
-
return;
|
|
25
|
+
return data;
|
|
76
26
|
}
|
|
77
|
-
|
|
78
|
-
value = initial_value;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
$: if (sources && !active_source) {
|
|
82
|
-
active_source = sources[0];
|
|
83
27
|
}
|
|
84
28
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
_video = value.video;
|
|
88
|
-
_subtitle = value.subtitles;
|
|
89
|
-
} else {
|
|
90
|
-
_video = null;
|
|
91
|
-
_subtitle = null;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
29
|
+
const gradio = new VideoGradio(props);
|
|
30
|
+
let old_value = $state(gradio.props.value);
|
|
94
31
|
|
|
95
|
-
let
|
|
32
|
+
let uploading = $state(false);
|
|
33
|
+
let dragging = $state(false);
|
|
34
|
+
let active_source = $derived.by(() =>
|
|
35
|
+
gradio.props.sources ? gradio.props.sources[0] : undefined
|
|
36
|
+
);
|
|
37
|
+
let initial_value: FileData | null = gradio.props.value;
|
|
96
38
|
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
old_value = value;
|
|
39
|
+
$effect(() => {
|
|
40
|
+
if (old_value != gradio.props.value) {
|
|
41
|
+
old_value = gradio.props.value;
|
|
100
42
|
gradio.dispatch("change");
|
|
101
43
|
}
|
|
102
|
-
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const handle_reset_value = (): void => {
|
|
47
|
+
if (initial_value === null || gradio.props.value === initial_value) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
gradio.props.value = initial_value;
|
|
51
|
+
};
|
|
103
52
|
|
|
104
53
|
function handle_change({ detail }: CustomEvent<FileData | null>): void {
|
|
105
54
|
if (detail != null) {
|
|
106
|
-
value =
|
|
107
|
-
video: FileData;
|
|
108
|
-
subtitles: FileData | null;
|
|
109
|
-
} | null;
|
|
55
|
+
gradio.props.value = detail as FileData;
|
|
110
56
|
} else {
|
|
111
|
-
value = null;
|
|
57
|
+
gradio.props.value = null;
|
|
112
58
|
}
|
|
113
59
|
}
|
|
114
60
|
|
|
@@ -116,44 +62,48 @@
|
|
|
116
62
|
const [level, status] = detail.includes("Invalid file type")
|
|
117
63
|
? ["warning", "complete"]
|
|
118
64
|
: ["error", "error"];
|
|
119
|
-
loading_status =
|
|
120
|
-
loading_status.
|
|
121
|
-
loading_status.message = detail;
|
|
65
|
+
gradio.shared.loading_status.status = status as any;
|
|
66
|
+
gradio.shared.loading_status.message = detail;
|
|
122
67
|
gradio.dispatch(level as "error" | "warning", detail);
|
|
123
68
|
}
|
|
124
69
|
</script>
|
|
125
70
|
|
|
126
|
-
{#if !interactive}
|
|
71
|
+
{#if !gradio.shared.interactive}
|
|
127
72
|
<Block
|
|
128
|
-
{visible}
|
|
129
|
-
variant={value === null && active_source === "upload"
|
|
73
|
+
visible={gradio.shared.visible}
|
|
74
|
+
variant={gradio.props.value === null && active_source === "upload"
|
|
75
|
+
? "dashed"
|
|
76
|
+
: "solid"}
|
|
130
77
|
border_mode={dragging ? "focus" : "base"}
|
|
131
78
|
padding={false}
|
|
132
|
-
{elem_id}
|
|
133
|
-
{elem_classes}
|
|
134
|
-
{height}
|
|
135
|
-
{width}
|
|
136
|
-
{container}
|
|
137
|
-
{scale}
|
|
138
|
-
{min_width}
|
|
79
|
+
elem_id={gradio.shared.elem_id}
|
|
80
|
+
elem_classes={gradio.shared.elem_classes}
|
|
81
|
+
height={gradio.props.height || undefined}
|
|
82
|
+
width={gradio.props.width}
|
|
83
|
+
container={gradio.shared.container}
|
|
84
|
+
scale={gradio.shared.scale}
|
|
85
|
+
min_width={gradio.shared.min_width}
|
|
139
86
|
allow_overflow={false}
|
|
140
87
|
>
|
|
141
88
|
<StatusTracker
|
|
142
|
-
autoscroll={gradio.autoscroll}
|
|
89
|
+
autoscroll={gradio.shared.autoscroll}
|
|
143
90
|
i18n={gradio.i18n}
|
|
144
|
-
{...loading_status}
|
|
145
|
-
on:clear_status={() =>
|
|
91
|
+
{...gradio.shared.loading_status}
|
|
92
|
+
on:clear_status={() =>
|
|
93
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
146
94
|
/>
|
|
147
95
|
|
|
148
96
|
<StaticVideo
|
|
149
|
-
value={
|
|
150
|
-
subtitle={
|
|
151
|
-
{label}
|
|
152
|
-
{show_label}
|
|
153
|
-
{autoplay}
|
|
154
|
-
{loop}
|
|
155
|
-
{
|
|
156
|
-
{
|
|
97
|
+
value={gradio.props.value}
|
|
98
|
+
subtitle={gradio.props.subtitles}
|
|
99
|
+
label={gradio.shared.label}
|
|
100
|
+
show_label={gradio.shared.show_label}
|
|
101
|
+
autoplay={gradio.props.autoplay}
|
|
102
|
+
loop={gradio.props.loop}
|
|
103
|
+
show_share_button={(gradio.props.buttons || []).includes("share")}
|
|
104
|
+
show_download_button={(gradio.props.buttons || ["download"]).includes(
|
|
105
|
+
"download"
|
|
106
|
+
)}
|
|
157
107
|
on:play={() => gradio.dispatch("play")}
|
|
158
108
|
on:pause={() => gradio.dispatch("pause")}
|
|
159
109
|
on:stop={() => gradio.dispatch("stop")}
|
|
@@ -161,50 +111,57 @@
|
|
|
161
111
|
on:share={({ detail }) => gradio.dispatch("share", detail)}
|
|
162
112
|
on:error={({ detail }) => gradio.dispatch("error", detail)}
|
|
163
113
|
i18n={gradio.i18n}
|
|
164
|
-
upload={(...args) => gradio.client.upload(...args)}
|
|
114
|
+
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
165
115
|
/>
|
|
166
116
|
</Block>
|
|
167
117
|
{:else}
|
|
168
118
|
<Block
|
|
169
|
-
{visible}
|
|
170
|
-
variant={value === null && active_source === "upload"
|
|
119
|
+
visible={gradio.shared.visible}
|
|
120
|
+
variant={gradio.props.value === null && active_source === "upload"
|
|
121
|
+
? "dashed"
|
|
122
|
+
: "solid"}
|
|
171
123
|
border_mode={dragging ? "focus" : "base"}
|
|
172
124
|
padding={false}
|
|
173
|
-
{elem_id}
|
|
174
|
-
{elem_classes}
|
|
175
|
-
{height}
|
|
176
|
-
{width}
|
|
177
|
-
{container}
|
|
178
|
-
{scale}
|
|
179
|
-
{min_width}
|
|
125
|
+
elem_id={gradio.shared.elem_id}
|
|
126
|
+
elem_classes={gradio.shared.elem_classes}
|
|
127
|
+
height={gradio.props.height || undefined}
|
|
128
|
+
width={gradio.props.width}
|
|
129
|
+
container={gradio.shared.container}
|
|
130
|
+
scale={gradio.shared.scale}
|
|
131
|
+
min_width={gradio.shared.min_width}
|
|
180
132
|
allow_overflow={false}
|
|
181
133
|
>
|
|
182
134
|
<StatusTracker
|
|
183
|
-
autoscroll={gradio.autoscroll}
|
|
135
|
+
autoscroll={gradio.shared.autoscroll}
|
|
184
136
|
i18n={gradio.i18n}
|
|
185
|
-
{...loading_status}
|
|
186
|
-
on:clear_status={() =>
|
|
137
|
+
{...gradio.shared.loading_status}
|
|
138
|
+
on:clear_status={() =>
|
|
139
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
187
140
|
/>
|
|
188
141
|
|
|
189
142
|
<Video
|
|
190
|
-
|
|
191
|
-
|
|
143
|
+
bind:upload_promise
|
|
144
|
+
value={gradio.props.value}
|
|
145
|
+
subtitle={gradio.props.subtitles}
|
|
192
146
|
on:change={handle_change}
|
|
193
147
|
on:drag={({ detail }) => (dragging = detail)}
|
|
194
148
|
on:error={handle_error}
|
|
195
149
|
bind:uploading
|
|
196
|
-
{label}
|
|
197
|
-
{show_label}
|
|
198
|
-
{
|
|
199
|
-
{sources}
|
|
150
|
+
label={gradio.shared.label}
|
|
151
|
+
show_label={gradio.shared.show_label}
|
|
152
|
+
show_download_button={(gradio.props.buttons || []).includes("download")}
|
|
153
|
+
sources={gradio.props.sources}
|
|
200
154
|
{active_source}
|
|
201
|
-
{webcam_options}
|
|
202
|
-
{include_audio}
|
|
203
|
-
{autoplay}
|
|
204
|
-
{root}
|
|
205
|
-
{loop}
|
|
155
|
+
webcam_options={gradio.props.webcam_options}
|
|
156
|
+
include_audio={gradio.props.include_audio}
|
|
157
|
+
autoplay={gradio.props.autoplay}
|
|
158
|
+
root={gradio.shared.root}
|
|
159
|
+
loop={gradio.props.loop}
|
|
206
160
|
{handle_reset_value}
|
|
207
|
-
on:clear={() =>
|
|
161
|
+
on:clear={() => {
|
|
162
|
+
gradio.props.value = null;
|
|
163
|
+
gradio.dispatch("clear");
|
|
164
|
+
}}
|
|
208
165
|
on:play={() => gradio.dispatch("play")}
|
|
209
166
|
on:pause={() => gradio.dispatch("pause")}
|
|
210
167
|
on:upload={() => gradio.dispatch("upload")}
|
|
@@ -213,9 +170,9 @@
|
|
|
213
170
|
on:start_recording={() => gradio.dispatch("start_recording")}
|
|
214
171
|
on:stop_recording={() => gradio.dispatch("stop_recording")}
|
|
215
172
|
i18n={gradio.i18n}
|
|
216
|
-
max_file_size={gradio.max_file_size}
|
|
217
|
-
upload={(...args) => gradio.client.upload(...args)}
|
|
218
|
-
stream_handler={(...args) => gradio.client.stream(...args)}
|
|
173
|
+
max_file_size={gradio.shared.max_file_size}
|
|
174
|
+
upload={(...args) => gradio.shared.client.upload(...args)}
|
|
175
|
+
stream_handler={(...args) => gradio.shared.client.stream(...args)}
|
|
219
176
|
>
|
|
220
177
|
<UploadText i18n={gradio.i18n} type="video" />
|
|
221
178
|
</Video>
|
package/Video.stories.svelte
CHANGED
|
@@ -46,11 +46,9 @@
|
|
|
46
46
|
name="Static video"
|
|
47
47
|
args={{
|
|
48
48
|
value: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
orig_name: "world.mp4"
|
|
53
|
-
}
|
|
49
|
+
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
50
|
+
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
51
|
+
orig_name: "world.mp4"
|
|
54
52
|
},
|
|
55
53
|
label: "world video",
|
|
56
54
|
show_label: true,
|
|
@@ -68,11 +66,9 @@
|
|
|
68
66
|
name="Static video with vertical video"
|
|
69
67
|
args={{
|
|
70
68
|
value: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
orig_name: "world_vertical.mp4"
|
|
75
|
-
}
|
|
69
|
+
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world_vertical.mp4",
|
|
70
|
+
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world_vertical.mp4",
|
|
71
|
+
orig_name: "world_vertical.mp4"
|
|
76
72
|
},
|
|
77
73
|
label: "world video",
|
|
78
74
|
show_label: true,
|
|
@@ -115,11 +111,9 @@
|
|
|
115
111
|
width: 400,
|
|
116
112
|
height: 400,
|
|
117
113
|
value: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
orig_name: "world.mp4"
|
|
122
|
-
}
|
|
114
|
+
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
115
|
+
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
116
|
+
orig_name: "world.mp4"
|
|
123
117
|
},
|
|
124
118
|
webcam_options: {
|
|
125
119
|
mirror: true,
|
|
@@ -132,11 +126,9 @@
|
|
|
132
126
|
name="Trim video"
|
|
133
127
|
args={{
|
|
134
128
|
value: {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
orig_name: "world.mp4"
|
|
139
|
-
}
|
|
129
|
+
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
130
|
+
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4",
|
|
131
|
+
orig_name: "world.mp4"
|
|
140
132
|
},
|
|
141
133
|
label: "world video",
|
|
142
134
|
show_label: true,
|
package/Video.test.ts
CHANGED
|
@@ -40,11 +40,8 @@ describe("Video", () => {
|
|
|
40
40
|
show_label: true,
|
|
41
41
|
loading_status,
|
|
42
42
|
value: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
46
|
-
},
|
|
47
|
-
subtitles: null
|
|
43
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
44
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
48
45
|
},
|
|
49
46
|
label: "Test Label",
|
|
50
47
|
root: "foo",
|
|
@@ -72,11 +69,8 @@ describe("Video", () => {
|
|
|
72
69
|
show_label: false,
|
|
73
70
|
loading_status,
|
|
74
71
|
value: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
78
|
-
},
|
|
79
|
-
subtitles: null
|
|
72
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
73
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
80
74
|
},
|
|
81
75
|
label: "Video Component",
|
|
82
76
|
root: "foo",
|
|
@@ -99,11 +93,8 @@ describe("Video", () => {
|
|
|
99
93
|
show_label: true,
|
|
100
94
|
loading_status,
|
|
101
95
|
value: {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
105
|
-
},
|
|
106
|
-
subtitles: null
|
|
96
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
97
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
107
98
|
},
|
|
108
99
|
root: "foo",
|
|
109
100
|
proxy_url: null,
|
|
@@ -130,11 +121,8 @@ describe("Video", () => {
|
|
|
130
121
|
loading_status,
|
|
131
122
|
interactive: false,
|
|
132
123
|
value: {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
136
|
-
},
|
|
137
|
-
subtitles: null
|
|
124
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
125
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
138
126
|
},
|
|
139
127
|
root: "foo",
|
|
140
128
|
proxy_url: null,
|
|
@@ -158,11 +146,8 @@ describe("Video", () => {
|
|
|
158
146
|
show_label: true,
|
|
159
147
|
loading_status,
|
|
160
148
|
value: {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
164
|
-
},
|
|
165
|
-
subtitles: null
|
|
149
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
150
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
166
151
|
},
|
|
167
152
|
root: "foo",
|
|
168
153
|
proxy_url: null,
|
|
@@ -187,11 +172,8 @@ describe("Video", () => {
|
|
|
187
172
|
loading_status,
|
|
188
173
|
interactive: false,
|
|
189
174
|
value: {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
193
|
-
},
|
|
194
|
-
subtitles: null
|
|
175
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
176
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
195
177
|
},
|
|
196
178
|
root: "foo",
|
|
197
179
|
proxy_url: null,
|
|
@@ -209,9 +191,7 @@ describe("Video", () => {
|
|
|
209
191
|
startButton.dispatchEvent(new Event("loadeddata"));
|
|
210
192
|
component.$set({
|
|
211
193
|
value: {
|
|
212
|
-
|
|
213
|
-
path: "https://gradio-builds.s3.amazonaws.com/demo-files/audio_sample.wav"
|
|
214
|
-
}
|
|
194
|
+
path: "https://gradio-builds.s3.amazonaws.com/demo-files/audio_sample.wav"
|
|
215
195
|
}
|
|
216
196
|
});
|
|
217
197
|
startButton.dispatchEvent(new Event("loadeddata"));
|
|
@@ -224,11 +204,8 @@ describe("Video", () => {
|
|
|
224
204
|
loading_status,
|
|
225
205
|
interactive: true,
|
|
226
206
|
value: {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
230
|
-
},
|
|
231
|
-
subtitles: null
|
|
207
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
208
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
232
209
|
},
|
|
233
210
|
root: "foo",
|
|
234
211
|
proxy_url: null,
|
|
@@ -246,11 +223,8 @@ describe("Video", () => {
|
|
|
246
223
|
startButton.dispatchEvent(new Event("loadeddata"));
|
|
247
224
|
component.$set({
|
|
248
225
|
value: {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
252
|
-
},
|
|
253
|
-
subtitles: null
|
|
226
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
227
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
254
228
|
}
|
|
255
229
|
});
|
|
256
230
|
startButton.dispatchEvent(new Event("loadeddata"));
|
|
@@ -258,10 +232,8 @@ describe("Video", () => {
|
|
|
258
232
|
});
|
|
259
233
|
test("renders video and download button", async () => {
|
|
260
234
|
const data = {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
264
|
-
}
|
|
235
|
+
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4",
|
|
236
|
+
url: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/a.mp4"
|
|
265
237
|
};
|
|
266
238
|
const results = await render(Video, {
|
|
267
239
|
interactive: false,
|
|
@@ -278,7 +250,7 @@ describe("Video", () => {
|
|
|
278
250
|
const downloadButton = results.getAllByTestId("download-div")[0];
|
|
279
251
|
expect(
|
|
280
252
|
downloadButton.getElementsByTagName("a")[0].getAttribute("href")
|
|
281
|
-
).toBe(data.
|
|
253
|
+
).toBe(data.path);
|
|
282
254
|
expect(
|
|
283
255
|
downloadButton.getElementsByTagName("button").length
|
|
284
256
|
).toBeGreaterThan(0);
|
|
@@ -308,11 +280,11 @@ describe("Video", () => {
|
|
|
308
280
|
|
|
309
281
|
const mock = listen("change");
|
|
310
282
|
|
|
311
|
-
(component.value = [
|
|
283
|
+
((component.value = [
|
|
312
284
|
{
|
|
313
285
|
path: "https://raw.githubusercontent.com/gradio-app/gradio/main/gradio/demo/video_component/files/b.mp4"
|
|
314
286
|
}
|
|
315
287
|
]),
|
|
316
|
-
assert.equal(mock.callCount, 1);
|
|
288
|
+
assert.equal(mock.callCount, 1));
|
|
317
289
|
});
|
|
318
290
|
});
|
package/dist/Example.svelte
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
import {} from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export let
|
|
7
|
-
export let
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Video from "./shared/Video.svelte";
|
|
3
|
+
import { playable } from "./shared/utils";
|
|
4
|
+
import { type FileData } from "@gradio/client";
|
|
5
|
+
|
|
6
|
+
export let type: "gallery" | "table";
|
|
7
|
+
export let selected = false;
|
|
8
|
+
export let value: null | FileData = null;
|
|
9
|
+
export let loop: boolean;
|
|
10
|
+
let video: HTMLVideoElement;
|
|
11
|
+
|
|
12
|
+
async function init(): Promise<void> {
|
|
13
|
+
video.muted = true;
|
|
14
|
+
video.playsInline = true;
|
|
15
|
+
video.controls = false;
|
|
16
|
+
video.setAttribute("muted", "");
|
|
17
|
+
|
|
18
|
+
await video.play();
|
|
19
|
+
video.pause();
|
|
20
|
+
}
|
|
17
21
|
</script>
|
|
18
22
|
|
|
19
23
|
{#if value}
|
|
@@ -31,7 +35,7 @@ async function init() {
|
|
|
31
35
|
on:loadeddata={init}
|
|
32
36
|
on:mouseover={video.play.bind(video)}
|
|
33
37
|
on:mouseout={video.pause.bind(video)}
|
|
34
|
-
src={value?.
|
|
38
|
+
src={value?.url}
|
|
35
39
|
is_stream={false}
|
|
36
40
|
{loop}
|
|
37
41
|
/>
|