@gradio/video 0.17.0 → 0.19.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 +28 -0
- package/Index.svelte +10 -5
- package/dist/Index.svelte +10 -5
- package/dist/shared/InteractiveVideo.svelte +2 -0
- package/dist/shared/InteractiveVideo.svelte.d.ts +1 -0
- package/dist/shared/Player.svelte +5 -0
- package/dist/shared/Player.svelte.d.ts +1 -0
- package/dist/shared/VideoPreview.svelte +9 -4
- package/dist/shared/VideoPreview.svelte.d.ts +4 -2
- package/dist/types.d.ts +6 -1
- package/package.json +9 -9
- package/shared/InteractiveVideo.svelte +2 -0
- package/shared/Player.svelte +5 -0
- package/shared/VideoPreview.svelte +9 -4
- package/types.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
# @gradio/video
|
|
2
|
+
|
|
3
|
+
## 0.19.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#12539](https://github.com/gradio-app/gradio/pull/12539) [`f1d83fa`](https://github.com/gradio-app/gradio/commit/f1d83fac3d6e4bad60cf896a026fa2d572f26073) - Add ability to add custom buttons to components. Thanks @abidlabs!
|
|
8
|
+
|
|
9
|
+
### Dependency updates
|
|
10
|
+
|
|
11
|
+
- @gradio/atoms@0.20.0
|
|
12
|
+
- @gradio/utils@0.11.0
|
|
13
|
+
- @gradio/client@2.0.1
|
|
14
|
+
- @gradio/statustracker@0.12.1
|
|
15
|
+
- @gradio/upload@0.17.3
|
|
16
|
+
- @gradio/image@0.25.0
|
|
17
|
+
|
|
18
|
+
## 0.18.0
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- [#12504](https://github.com/gradio-app/gradio/pull/12504) [`4476400`](https://github.com/gradio-app/gradio/commit/44764009dfebecf894298efe80366e42578ea65d) - Add `playback_position` to gr.Audio and gr.Video, which can be updated and read. Thanks @aliabid94!
|
|
23
|
+
|
|
24
|
+
## 0.17.0
|
|
25
|
+
|
|
26
|
+
### Dependency updates
|
|
27
|
+
|
|
28
|
+
- @gradio/utils@0.10.4
|
|
29
|
+
|
|
2
30
|
## 0.17.0
|
|
3
31
|
|
|
4
32
|
### Features
|
package/Index.svelte
CHANGED
|
@@ -100,10 +100,11 @@
|
|
|
100
100
|
show_label={gradio.shared.show_label}
|
|
101
101
|
autoplay={gradio.props.autoplay}
|
|
102
102
|
loop={gradio.props.loop}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
|
|
103
|
+
buttons={gradio.props.buttons ?? ["download", "share"]}
|
|
104
|
+
on_custom_button_click={(id) => {
|
|
105
|
+
gradio.dispatch("custom_button_click", { id });
|
|
106
|
+
}}
|
|
107
|
+
bind:playback_position={gradio.props.playback_position}
|
|
107
108
|
on:play={() => gradio.dispatch("play")}
|
|
108
109
|
on:pause={() => gradio.dispatch("pause")}
|
|
109
110
|
on:stop={() => gradio.dispatch("stop")}
|
|
@@ -149,7 +150,10 @@
|
|
|
149
150
|
bind:uploading
|
|
150
151
|
label={gradio.shared.label}
|
|
151
152
|
show_label={gradio.shared.show_label}
|
|
152
|
-
|
|
153
|
+
buttons={gradio.props.buttons ?? ["download", "share"]}
|
|
154
|
+
on_custom_button_click={(id) => {
|
|
155
|
+
gradio.dispatch("custom_button_click", { id });
|
|
156
|
+
}}
|
|
153
157
|
sources={gradio.props.sources}
|
|
154
158
|
{active_source}
|
|
155
159
|
webcam_options={gradio.props.webcam_options}
|
|
@@ -158,6 +162,7 @@
|
|
|
158
162
|
root={gradio.shared.root}
|
|
159
163
|
loop={gradio.props.loop}
|
|
160
164
|
{handle_reset_value}
|
|
165
|
+
bind:playback_position={gradio.props.playback_position}
|
|
161
166
|
on:clear={() => {
|
|
162
167
|
gradio.props.value = null;
|
|
163
168
|
gradio.dispatch("clear");
|
package/dist/Index.svelte
CHANGED
|
@@ -100,10 +100,11 @@
|
|
|
100
100
|
show_label={gradio.shared.show_label}
|
|
101
101
|
autoplay={gradio.props.autoplay}
|
|
102
102
|
loop={gradio.props.loop}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
|
|
103
|
+
buttons={gradio.props.buttons ?? ["download", "share"]}
|
|
104
|
+
on_custom_button_click={(id) => {
|
|
105
|
+
gradio.dispatch("custom_button_click", { id });
|
|
106
|
+
}}
|
|
107
|
+
bind:playback_position={gradio.props.playback_position}
|
|
107
108
|
on:play={() => gradio.dispatch("play")}
|
|
108
109
|
on:pause={() => gradio.dispatch("pause")}
|
|
109
110
|
on:stop={() => gradio.dispatch("stop")}
|
|
@@ -149,7 +150,10 @@
|
|
|
149
150
|
bind:uploading
|
|
150
151
|
label={gradio.shared.label}
|
|
151
152
|
show_label={gradio.shared.show_label}
|
|
152
|
-
|
|
153
|
+
buttons={gradio.props.buttons ?? ["download", "share"]}
|
|
154
|
+
on_custom_button_click={(id) => {
|
|
155
|
+
gradio.dispatch("custom_button_click", { id });
|
|
156
|
+
}}
|
|
153
157
|
sources={gradio.props.sources}
|
|
154
158
|
{active_source}
|
|
155
159
|
webcam_options={gradio.props.webcam_options}
|
|
@@ -158,6 +162,7 @@
|
|
|
158
162
|
root={gradio.shared.root}
|
|
159
163
|
loop={gradio.props.loop}
|
|
160
164
|
{handle_reset_value}
|
|
165
|
+
bind:playback_position={gradio.props.playback_position}
|
|
161
166
|
on:clear={() => {
|
|
162
167
|
gradio.props.value = null;
|
|
163
168
|
gradio.dispatch("clear");
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
export let loop: boolean;
|
|
35
35
|
export let uploading = false;
|
|
36
36
|
export let upload_promise: Promise<any> | null = null;
|
|
37
|
+
export let playback_position = 0;
|
|
37
38
|
|
|
38
39
|
let has_change_history = false;
|
|
39
40
|
|
|
@@ -139,6 +140,7 @@
|
|
|
139
140
|
{show_download_button}
|
|
140
141
|
{handle_clear}
|
|
141
142
|
{has_change_history}
|
|
143
|
+
bind:playback_position
|
|
142
144
|
/>
|
|
143
145
|
{/key}
|
|
144
146
|
{:else if value.size}
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
export let value: FileData | null = null;
|
|
26
26
|
export let handle_clear: () => void = () => {};
|
|
27
27
|
export let has_change_history = false;
|
|
28
|
+
export let playback_position = 0;
|
|
28
29
|
|
|
29
30
|
const dispatch = createEventDispatcher<{
|
|
30
31
|
play: undefined;
|
|
@@ -100,6 +101,10 @@
|
|
|
100
101
|
|
|
101
102
|
$: time = time || 0;
|
|
102
103
|
$: duration = duration || 0;
|
|
104
|
+
$: playback_position = time;
|
|
105
|
+
$: if (playback_position !== time && video) {
|
|
106
|
+
video.currentTime = playback_position;
|
|
107
|
+
}
|
|
103
108
|
</script>
|
|
104
109
|
|
|
105
110
|
<div class="wrap">
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import type { FileData, Client } from "@gradio/client";
|
|
12
12
|
import { Video, Download } from "@gradio/icons";
|
|
13
13
|
import { uploadToHuggingFace } from "@gradio/utils";
|
|
14
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
14
15
|
|
|
15
16
|
import Player from "./Player.svelte";
|
|
16
17
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
@@ -20,12 +21,13 @@
|
|
|
20
21
|
export let label: string | undefined = undefined;
|
|
21
22
|
export let show_label = true;
|
|
22
23
|
export let autoplay: boolean;
|
|
23
|
-
export let
|
|
24
|
-
export let
|
|
24
|
+
export let buttons: (string | CustomButtonType)[] | null = null;
|
|
25
|
+
export let on_custom_button_click: ((id: number) => void) | null = null;
|
|
25
26
|
export let loop: boolean;
|
|
26
27
|
export let i18n: I18nFormatter;
|
|
27
28
|
export let upload: Client["upload"];
|
|
28
29
|
export let display_icon_button_wrapper_top_corner = false;
|
|
30
|
+
export let playback_position = 0;
|
|
29
31
|
|
|
30
32
|
let old_value: FileData | null = null;
|
|
31
33
|
let old_subtitle: FileData | null = null;
|
|
@@ -84,13 +86,16 @@
|
|
|
84
86
|
interactive={false}
|
|
85
87
|
{upload}
|
|
86
88
|
{i18n}
|
|
89
|
+
bind:playback_position
|
|
87
90
|
/>
|
|
88
91
|
{/key}
|
|
89
92
|
<div data-testid="download-div">
|
|
90
93
|
<IconButtonWrapper
|
|
91
94
|
display_top_corner={display_icon_button_wrapper_top_corner}
|
|
95
|
+
buttons={buttons ?? ["download", "share"]}
|
|
96
|
+
{on_custom_button_click}
|
|
92
97
|
>
|
|
93
|
-
{#if
|
|
98
|
+
{#if buttons?.some((btn) => typeof btn === "string" && btn === "download")}
|
|
94
99
|
<DownloadLink
|
|
95
100
|
href={value.is_stream
|
|
96
101
|
? value.url?.replace("playlist.m3u8", "playlist-file")
|
|
@@ -100,7 +105,7 @@
|
|
|
100
105
|
<IconButton Icon={Download} label="Download" />
|
|
101
106
|
</DownloadLink>
|
|
102
107
|
{/if}
|
|
103
|
-
{#if
|
|
108
|
+
{#if buttons?.some((btn) => typeof btn === "string" && btn === "share")}
|
|
104
109
|
<ShareButton
|
|
105
110
|
{i18n}
|
|
106
111
|
on:error
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FileData, Client } from "@gradio/client";
|
|
2
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
2
3
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
3
4
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
5
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
@@ -19,12 +20,13 @@ declare const VideoPreview: $$__sveltets_2_IsomorphicComponent<{
|
|
|
19
20
|
label?: string | undefined;
|
|
20
21
|
show_label?: boolean;
|
|
21
22
|
autoplay: boolean;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
buttons?: (string | CustomButtonType)[] | null;
|
|
24
|
+
on_custom_button_click?: ((id: number) => void) | null;
|
|
24
25
|
loop: boolean;
|
|
25
26
|
i18n: I18nFormatter;
|
|
26
27
|
upload: Client["upload"];
|
|
27
28
|
display_icon_button_wrapper_top_corner?: boolean;
|
|
29
|
+
playback_position?: number;
|
|
28
30
|
}, {
|
|
29
31
|
play: CustomEvent<any>;
|
|
30
32
|
pause: CustomEvent<any>;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type { FileData } from "@gradio/client";
|
|
2
2
|
import type { LoadingStatus } from "@gradio/statustracker";
|
|
3
|
+
import type { CustomButton } from "@gradio/utils";
|
|
3
4
|
import type { WebcamOptions } from "./shared/utils";
|
|
4
5
|
export interface VideoProps {
|
|
5
6
|
value: FileData | null;
|
|
6
7
|
height: number | undefined;
|
|
7
8
|
width: number | undefined;
|
|
8
9
|
autoplay: boolean;
|
|
9
|
-
buttons: ("share" | "download" | "fullscreen")[];
|
|
10
|
+
buttons: ("share" | "download" | "fullscreen" | CustomButton)[];
|
|
10
11
|
sources: ["webcam"] | ["upload"] | ["webcam", "upload"] | ["upload", "webcam"];
|
|
11
12
|
webcam_options: WebcamOptions;
|
|
12
13
|
include_audio: boolean;
|
|
13
14
|
loop: boolean;
|
|
14
15
|
webcam_constraints: object;
|
|
15
16
|
subtitles: FileData | null;
|
|
17
|
+
playback_position: number;
|
|
16
18
|
}
|
|
17
19
|
export interface VideoEvents {
|
|
18
20
|
change: never;
|
|
@@ -28,4 +30,7 @@ export interface VideoEvents {
|
|
|
28
30
|
share: any;
|
|
29
31
|
error: any;
|
|
30
32
|
warning: any;
|
|
33
|
+
custom_button_click: {
|
|
34
|
+
id: number;
|
|
35
|
+
};
|
|
31
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/video",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
"@ffmpeg/util": "^0.12.2",
|
|
12
12
|
"hls.js": "^1.6.13",
|
|
13
13
|
"mrmime": "^2.0.1",
|
|
14
|
-
"@gradio/
|
|
15
|
-
"@gradio/
|
|
16
|
-
"@gradio/
|
|
17
|
-
"@gradio/image": "^0.
|
|
18
|
-
"@gradio/
|
|
19
|
-
"@gradio/
|
|
20
|
-
"@gradio/
|
|
14
|
+
"@gradio/atoms": "^0.20.0",
|
|
15
|
+
"@gradio/client": "^2.0.1",
|
|
16
|
+
"@gradio/statustracker": "^0.12.1",
|
|
17
|
+
"@gradio/image": "^0.25.0",
|
|
18
|
+
"@gradio/upload": "^0.17.3",
|
|
19
|
+
"@gradio/utils": "^0.11.0",
|
|
20
|
+
"@gradio/icons": "^0.15.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@gradio/preview": "^0.15.
|
|
23
|
+
"@gradio/preview": "^0.15.1"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
26
|
"./package.json": "./package.json",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
export let loop: boolean;
|
|
35
35
|
export let uploading = false;
|
|
36
36
|
export let upload_promise: Promise<any> | null = null;
|
|
37
|
+
export let playback_position = 0;
|
|
37
38
|
|
|
38
39
|
let has_change_history = false;
|
|
39
40
|
|
|
@@ -139,6 +140,7 @@
|
|
|
139
140
|
{show_download_button}
|
|
140
141
|
{handle_clear}
|
|
141
142
|
{has_change_history}
|
|
143
|
+
bind:playback_position
|
|
142
144
|
/>
|
|
143
145
|
{/key}
|
|
144
146
|
{:else if value.size}
|
package/shared/Player.svelte
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
export let value: FileData | null = null;
|
|
26
26
|
export let handle_clear: () => void = () => {};
|
|
27
27
|
export let has_change_history = false;
|
|
28
|
+
export let playback_position = 0;
|
|
28
29
|
|
|
29
30
|
const dispatch = createEventDispatcher<{
|
|
30
31
|
play: undefined;
|
|
@@ -100,6 +101,10 @@
|
|
|
100
101
|
|
|
101
102
|
$: time = time || 0;
|
|
102
103
|
$: duration = duration || 0;
|
|
104
|
+
$: playback_position = time;
|
|
105
|
+
$: if (playback_position !== time && video) {
|
|
106
|
+
video.currentTime = playback_position;
|
|
107
|
+
}
|
|
103
108
|
</script>
|
|
104
109
|
|
|
105
110
|
<div class="wrap">
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import type { FileData, Client } from "@gradio/client";
|
|
12
12
|
import { Video, Download } from "@gradio/icons";
|
|
13
13
|
import { uploadToHuggingFace } from "@gradio/utils";
|
|
14
|
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
|
14
15
|
|
|
15
16
|
import Player from "./Player.svelte";
|
|
16
17
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
@@ -20,12 +21,13 @@
|
|
|
20
21
|
export let label: string | undefined = undefined;
|
|
21
22
|
export let show_label = true;
|
|
22
23
|
export let autoplay: boolean;
|
|
23
|
-
export let
|
|
24
|
-
export let
|
|
24
|
+
export let buttons: (string | CustomButtonType)[] | null = null;
|
|
25
|
+
export let on_custom_button_click: ((id: number) => void) | null = null;
|
|
25
26
|
export let loop: boolean;
|
|
26
27
|
export let i18n: I18nFormatter;
|
|
27
28
|
export let upload: Client["upload"];
|
|
28
29
|
export let display_icon_button_wrapper_top_corner = false;
|
|
30
|
+
export let playback_position = 0;
|
|
29
31
|
|
|
30
32
|
let old_value: FileData | null = null;
|
|
31
33
|
let old_subtitle: FileData | null = null;
|
|
@@ -84,13 +86,16 @@
|
|
|
84
86
|
interactive={false}
|
|
85
87
|
{upload}
|
|
86
88
|
{i18n}
|
|
89
|
+
bind:playback_position
|
|
87
90
|
/>
|
|
88
91
|
{/key}
|
|
89
92
|
<div data-testid="download-div">
|
|
90
93
|
<IconButtonWrapper
|
|
91
94
|
display_top_corner={display_icon_button_wrapper_top_corner}
|
|
95
|
+
buttons={buttons ?? ["download", "share"]}
|
|
96
|
+
{on_custom_button_click}
|
|
92
97
|
>
|
|
93
|
-
{#if
|
|
98
|
+
{#if buttons?.some((btn) => typeof btn === "string" && btn === "download")}
|
|
94
99
|
<DownloadLink
|
|
95
100
|
href={value.is_stream
|
|
96
101
|
? value.url?.replace("playlist.m3u8", "playlist-file")
|
|
@@ -100,7 +105,7 @@
|
|
|
100
105
|
<IconButton Icon={Download} label="Download" />
|
|
101
106
|
</DownloadLink>
|
|
102
107
|
{/if}
|
|
103
|
-
{#if
|
|
108
|
+
{#if buttons?.some((btn) => typeof btn === "string" && btn === "share")}
|
|
104
109
|
<ShareButton
|
|
105
110
|
{i18n}
|
|
106
111
|
on:error
|
package/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FileData } from "@gradio/client";
|
|
2
2
|
import type { LoadingStatus } from "@gradio/statustracker";
|
|
3
|
+
import type { CustomButton } from "@gradio/utils";
|
|
3
4
|
import type { WebcamOptions } from "./shared/utils";
|
|
4
5
|
|
|
5
6
|
export interface VideoProps {
|
|
@@ -7,7 +8,7 @@ export interface VideoProps {
|
|
|
7
8
|
height: number | undefined;
|
|
8
9
|
width: number | undefined;
|
|
9
10
|
autoplay: boolean;
|
|
10
|
-
buttons: ("share" | "download" | "fullscreen")[];
|
|
11
|
+
buttons: ("share" | "download" | "fullscreen" | CustomButton)[];
|
|
11
12
|
sources:
|
|
12
13
|
| ["webcam"]
|
|
13
14
|
| ["upload"]
|
|
@@ -18,6 +19,7 @@ export interface VideoProps {
|
|
|
18
19
|
loop: boolean;
|
|
19
20
|
webcam_constraints: object;
|
|
20
21
|
subtitles: FileData | null;
|
|
22
|
+
playback_position: number;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export interface VideoEvents {
|
|
@@ -34,4 +36,5 @@ export interface VideoEvents {
|
|
|
34
36
|
share: any;
|
|
35
37
|
error: any;
|
|
36
38
|
warning: any;
|
|
39
|
+
custom_button_click: { id: number };
|
|
37
40
|
}
|