@gradio/video 0.1.9 → 0.2.0
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 +11 -0
- package/Example.svelte +8 -2
- package/Video.stories.svelte +17 -1
- package/package.json +8 -8
- package/shared/Player.svelte +11 -1
- package/shared/Video.svelte +60 -50
- package/shared/VideoPreview.svelte +3 -6
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# @gradio/video
|
2
2
|
|
3
|
+
## 0.2.0
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- [#6726](https://github.com/gradio-app/gradio/pull/6726) [`21cfb0a`](https://github.com/gradio-app/gradio/commit/21cfb0acc309bb1a392f4d8a8e42f6be864c5978) - Remove the styles from the Image/Video primitive components and Fix the container styles. Thanks [@whitphx](https://github.com/whitphx)!
|
8
|
+
- [#6398](https://github.com/gradio-app/gradio/pull/6398) [`67ddd40`](https://github.com/gradio-app/gradio/commit/67ddd40b4b70d3a37cb1637c33620f8d197dbee0) - Lite v4. Thanks [@whitphx](https://github.com/whitphx)!
|
9
|
+
|
10
|
+
### Fixes
|
11
|
+
|
12
|
+
- [#6698](https://github.com/gradio-app/gradio/pull/6698) [`798eca5`](https://github.com/gradio-app/gradio/commit/798eca524d44289c536c47eec7c4fdce9fe81905) - Fit video media within Video component. Thanks [@hannahblair](https://github.com/hannahblair)!
|
13
|
+
|
3
14
|
## 0.1.9
|
4
15
|
|
5
16
|
### Fixes
|
package/Example.svelte
CHANGED
@@ -43,10 +43,13 @@
|
|
43
43
|
<style>
|
44
44
|
.container {
|
45
45
|
flex: none;
|
46
|
-
border: 2px solid var(--border-color-primary);
|
47
|
-
border-radius: var(--radius-lg);
|
48
46
|
max-width: none;
|
49
47
|
}
|
48
|
+
.container :global(video) {
|
49
|
+
width: var(--size-full);
|
50
|
+
height: var(--size-full);
|
51
|
+
object-fit: cover;
|
52
|
+
}
|
50
53
|
|
51
54
|
.container:hover,
|
52
55
|
.container.selected {
|
@@ -54,6 +57,9 @@
|
|
54
57
|
}
|
55
58
|
.container.table {
|
56
59
|
margin: 0 auto;
|
60
|
+
border: 2px solid var(--border-color-primary);
|
61
|
+
border-radius: var(--radius-lg);
|
62
|
+
overflow: hidden;
|
57
63
|
width: var(--size-20);
|
58
64
|
height: var(--size-20);
|
59
65
|
object-fit: cover;
|
package/Video.stories.svelte
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
import { format } from "svelte-i18n";
|
5
5
|
import { get } from "svelte/store";
|
6
6
|
import { userEvent, within } from "@storybook/testing-library";
|
7
|
-
import { waitFor } from "@testing-library/dom";
|
8
7
|
</script>
|
9
8
|
|
10
9
|
<Meta title="Components/Video" component={Video} />
|
@@ -44,6 +43,23 @@
|
|
44
43
|
width: 400
|
45
44
|
}}
|
46
45
|
/>
|
46
|
+
<Story
|
47
|
+
name="Static video with vertical video"
|
48
|
+
args={{
|
49
|
+
value: {
|
50
|
+
video: {
|
51
|
+
path: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world_vertical.mp4",
|
52
|
+
url: "https://gradio-static-files.s3.us-west-2.amazonaws.com/world_vertical.mp4",
|
53
|
+
orig_name: "world_vertical.mp4"
|
54
|
+
}
|
55
|
+
},
|
56
|
+
label: "world video",
|
57
|
+
show_label: true,
|
58
|
+
interactive: false,
|
59
|
+
height: 200,
|
60
|
+
width: 400
|
61
|
+
}}
|
62
|
+
/>
|
47
63
|
|
48
64
|
<Story
|
49
65
|
name="Upload video"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gradio/video",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.2.0",
|
4
4
|
"description": "Gradio UI packages",
|
5
5
|
"type": "module",
|
6
6
|
"author": "",
|
@@ -9,14 +9,14 @@
|
|
9
9
|
"dependencies": {
|
10
10
|
"@ffmpeg/ffmpeg": "^0.12.7",
|
11
11
|
"@ffmpeg/util": "^0.12.1",
|
12
|
-
"@gradio/atoms": "^0.
|
13
|
-
"@gradio/client": "^0.
|
14
|
-
"@gradio/icons": "^0.3.
|
15
|
-
"@gradio/
|
16
|
-
"@gradio/
|
17
|
-
"@gradio/
|
12
|
+
"@gradio/atoms": "^0.4.0",
|
13
|
+
"@gradio/client": "^0.9.0",
|
14
|
+
"@gradio/icons": "^0.3.2",
|
15
|
+
"@gradio/statustracker": "^0.4.2",
|
16
|
+
"@gradio/image": "^0.5.0",
|
17
|
+
"@gradio/upload": "^0.5.3",
|
18
18
|
"@gradio/utils": "^0.2.0",
|
19
|
-
"@gradio/
|
19
|
+
"@gradio/wasm": "^0.4.0"
|
20
20
|
},
|
21
21
|
"devDependencies": {
|
22
22
|
"mrmime": "^1.0.1"
|
package/shared/Player.svelte
CHANGED
@@ -99,7 +99,7 @@
|
|
99
99
|
</script>
|
100
100
|
|
101
101
|
<div class="wrap">
|
102
|
-
<div class:mirror>
|
102
|
+
<div class="mirror-wrap" class:mirror>
|
103
103
|
<Video
|
104
104
|
{src}
|
105
105
|
preload="auto"
|
@@ -199,6 +199,12 @@
|
|
199
199
|
transform: scaleX(-1);
|
200
200
|
}
|
201
201
|
|
202
|
+
.mirror-wrap {
|
203
|
+
position: relative;
|
204
|
+
height: 100%;
|
205
|
+
width: 100%;
|
206
|
+
}
|
207
|
+
|
202
208
|
.controls {
|
203
209
|
position: absolute;
|
204
210
|
bottom: 0;
|
@@ -248,4 +254,8 @@
|
|
248
254
|
width: var(--size-full);
|
249
255
|
border-radius: var(--radius-xl);
|
250
256
|
}
|
257
|
+
.wrap :global(video) {
|
258
|
+
height: var(--size-full);
|
259
|
+
width: var(--size-full);
|
260
|
+
}
|
251
261
|
</style>
|
package/shared/Video.svelte
CHANGED
@@ -22,50 +22,69 @@
|
|
22
22
|
export let processingVideo = false;
|
23
23
|
|
24
24
|
const dispatch = createEventDispatcher();
|
25
|
+
|
26
|
+
let resolved_src: typeof src;
|
27
|
+
|
28
|
+
// The `src` prop can be updated before the Promise from `resolve_wasm_src` is resolved.
|
29
|
+
// In such a case, the resolved value for the old `src` has to be discarded,
|
30
|
+
// This variable `latest_src` is used to pick up only the value resolved for the latest `src` prop.
|
31
|
+
let latest_src: typeof src;
|
32
|
+
$: {
|
33
|
+
// In normal (non-Wasm) Gradio, the `<img>` element should be rendered with the passed `src` props immediately
|
34
|
+
// without waiting for `resolve_wasm_src()` to resolve.
|
35
|
+
// If it waits, a black image is displayed until the async task finishes
|
36
|
+
// and it leads to undesirable flickering.
|
37
|
+
// So set `src` to `resolved_src` here.
|
38
|
+
resolved_src = src;
|
39
|
+
|
40
|
+
latest_src = src;
|
41
|
+
const resolving_src = src;
|
42
|
+
resolve_wasm_src(resolving_src).then((s) => {
|
43
|
+
if (latest_src === resolving_src) {
|
44
|
+
resolved_src = s;
|
45
|
+
}
|
46
|
+
});
|
47
|
+
}
|
25
48
|
</script>
|
26
49
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
Then, even when `controls` is false, the compiled DOM would be `<video controls="false">` which is equivalent to `<video controls>` since the string "false" is even truthy.
|
50
|
+
<!--
|
51
|
+
The spread operator with `$$props` or `$$restProps` can't be used here
|
52
|
+
to pass props from the parent component to the <video> element
|
53
|
+
because of its unexpected behavior: https://github.com/sveltejs/svelte/issues/7404
|
54
|
+
For example, if we add {...$$props} or {...$$restProps}, the boolean props aside it like `controls` will be compiled as string "true" or "false" on the actual DOM.
|
55
|
+
Then, even when `controls` is false, the compiled DOM would be `<video controls="false">` which is equivalent to `<video controls>` since the string "false" is even truthy.
|
34
56
|
-->
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
{:catch error}
|
67
|
-
<p style="color: red;">{error.message}</p>
|
68
|
-
{/await}
|
57
|
+
<div class:hidden={!processingVideo} class="overlay">
|
58
|
+
<span class="load-wrap">
|
59
|
+
<span class="loader" />
|
60
|
+
</span>
|
61
|
+
</div>
|
62
|
+
<video
|
63
|
+
src={resolved_src}
|
64
|
+
{muted}
|
65
|
+
{playsinline}
|
66
|
+
{preload}
|
67
|
+
{autoplay}
|
68
|
+
{controls}
|
69
|
+
on:loadeddata={dispatch.bind(null, "loadeddata")}
|
70
|
+
on:click={dispatch.bind(null, "click")}
|
71
|
+
on:play={dispatch.bind(null, "play")}
|
72
|
+
on:pause={dispatch.bind(null, "pause")}
|
73
|
+
on:ended={dispatch.bind(null, "ended")}
|
74
|
+
on:mouseover={dispatch.bind(null, "mouseover")}
|
75
|
+
on:mouseout={dispatch.bind(null, "mouseout")}
|
76
|
+
on:focus={dispatch.bind(null, "focus")}
|
77
|
+
on:blur={dispatch.bind(null, "blur")}
|
78
|
+
bind:currentTime
|
79
|
+
bind:duration
|
80
|
+
bind:paused
|
81
|
+
bind:this={node}
|
82
|
+
use:loaded={{ autoplay: autoplay ?? false }}
|
83
|
+
data-testid={$$props["data-testid"]}
|
84
|
+
crossorigin="anonymous"
|
85
|
+
>
|
86
|
+
<slot />
|
87
|
+
</video>
|
69
88
|
|
70
89
|
<style>
|
71
90
|
.overlay {
|
@@ -121,13 +140,4 @@
|
|
121
140
|
background: #fff;
|
122
141
|
}
|
123
142
|
}
|
124
|
-
|
125
|
-
video {
|
126
|
-
position: inherit;
|
127
|
-
background-color: black;
|
128
|
-
width: var(--size-full);
|
129
|
-
height: var(--size-full);
|
130
|
-
object-fit: contain;
|
131
|
-
border-radius: var(--radius-xl);
|
132
|
-
}
|
133
143
|
</style>
|
@@ -4,6 +4,7 @@
|
|
4
4
|
import type { FileData } from "@gradio/client";
|
5
5
|
import { Video, Download } from "@gradio/icons";
|
6
6
|
import { uploadToHuggingFace } from "@gradio/utils";
|
7
|
+
import { DownloadLink } from "@gradio/wasm/svelte";
|
7
8
|
|
8
9
|
import Player from "./Player.svelte";
|
9
10
|
import type { I18nFormatter } from "js/app/src/gradio_helper";
|
@@ -67,13 +68,9 @@
|
|
67
68
|
{/key}
|
68
69
|
<div class="icon-buttons" data-testid="download-div">
|
69
70
|
{#if show_download_button}
|
70
|
-
<
|
71
|
-
href={value.url}
|
72
|
-
target={window.__is_colab__ ? "_blank" : null}
|
73
|
-
download={value.orig_name || value.path}
|
74
|
-
>
|
71
|
+
<DownloadLink href={value.url} download={value.orig_name || value.path}>
|
75
72
|
<IconButton Icon={Download} label="Download" />
|
76
|
-
</
|
73
|
+
</DownloadLink>
|
77
74
|
{/if}
|
78
75
|
{#if show_share_button}
|
79
76
|
<ShareButton
|