@gradio/video 0.1.9 → 0.2.1

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 CHANGED
@@ -1,10 +1,30 @@
1
1
  # @gradio/video
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`5d51fbc`](https://github.com/gradio-app/gradio/commit/5d51fbce7826da840a2fd4940feb5d9ad6f1bc5a), [`34f9431`](https://github.com/gradio-app/gradio/commit/34f943101bf7dd6b8a8974a6131c1ed7c4a0dac0)]:
8
+ - @gradio/upload@0.5.4
9
+ - @gradio/client@0.9.1
10
+ - @gradio/image@0.5.1
11
+
12
+ ## 0.2.0
13
+
14
+ ### Features
15
+
16
+ - [#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)!
17
+ - [#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)!
18
+
19
+ ### Fixes
20
+
21
+ - [#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)!
22
+
3
23
  ## 0.1.9
4
24
 
5
25
  ### Fixes
6
26
 
7
- - [#6566](https://github.com/gradio-app/gradio/pull/6566) [`d548202`](https://github.com/gradio-app/gradio/commit/d548202d2b5bd8a99e3ebc5bf56820b0282ce0f5) - Improve video trimming and error handling. Thanks [@hannahblair](https://github.com/hannahblair)!
27
+ - [#6566](https://github.com/gradio-app/gradio/pull/6566) [`d548202`](https://github.com/gradio-app/gradio/commit/d548202d2b5bd8a99e3ebc5bf56820b0282ce0f5) - Improve video trimming and error handling. Thanks [@hannahblair](https://github.com/hannahblair)!
8
28
 
9
29
  ## 0.1.8
10
30
 
@@ -234,4 +254,4 @@ Thanks [@pngwn](https://github.com/pngwn)!
234
254
  - @gradio/image@0.1.0
235
255
  - @gradio/utils@0.0.2
236
256
  - @gradio/atoms@0.0.2
237
- - @gradio/upload@0.0.2
257
+ - @gradio/upload@0.0.2
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;
@@ -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.1.9",
3
+ "version": "0.2.1",
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.3.1",
13
- "@gradio/client": "^0.8.2",
14
- "@gradio/icons": "^0.3.1",
15
- "@gradio/image": "^0.4.2",
16
- "@gradio/statustracker": "^0.4.1",
17
- "@gradio/wasm": "^0.3.0",
12
+ "@gradio/atoms": "^0.4.0",
13
+ "@gradio/client": "^0.9.1",
14
+ "@gradio/image": "^0.5.1",
15
+ "@gradio/upload": "^0.5.4",
16
+ "@gradio/icons": "^0.3.2",
17
+ "@gradio/wasm": "^0.4.0",
18
18
  "@gradio/utils": "^0.2.0",
19
- "@gradio/upload": "^0.5.2"
19
+ "@gradio/statustracker": "^0.4.2"
20
20
  },
21
21
  "devDependencies": {
22
22
  "mrmime": "^1.0.1"
@@ -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>
@@ -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
- {#await resolve_wasm_src(src) then resolved_src}
28
- <!--
29
- The spread operator with `$$props` or `$$restProps` can't be used here
30
- to pass props from the parent component to the <video> element
31
- because of its unexpected behavior: https://github.com/sveltejs/svelte/issues/7404
32
- 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.
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
- <div class:hidden={!processingVideo} class="overlay">
36
- <span class="load-wrap">
37
- <span class="loader" />
38
- </span>
39
- </div>
40
- <video
41
- src={resolved_src}
42
- {muted}
43
- {playsinline}
44
- {preload}
45
- {autoplay}
46
- {controls}
47
- on:loadeddata={dispatch.bind(null, "loadeddata")}
48
- on:click={dispatch.bind(null, "click")}
49
- on:play={dispatch.bind(null, "play")}
50
- on:pause={dispatch.bind(null, "pause")}
51
- on:ended={dispatch.bind(null, "ended")}
52
- on:mouseover={dispatch.bind(null, "mouseover")}
53
- on:mouseout={dispatch.bind(null, "mouseout")}
54
- on:focus={dispatch.bind(null, "focus")}
55
- on:blur={dispatch.bind(null, "blur")}
56
- bind:currentTime
57
- bind:duration
58
- bind:paused
59
- bind:this={node}
60
- use:loaded={{ autoplay: autoplay ?? false }}
61
- data-testid={$$props["data-testid"]}
62
- crossorigin="anonymous"
63
- >
64
- <slot />
65
- </video>
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
- <a
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
- </a>
73
+ </DownloadLink>
77
74
  {/if}
78
75
  {#if show_share_button}
79
76
  <ShareButton