@gradio/video 0.15.0 → 0.16.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 +42 -0
- package/Index.svelte +1 -1
- package/dist/Example.svelte.d.ts +3 -1
- package/dist/Index.svelte +7 -10
- package/dist/Index.svelte.d.ts +14 -12
- package/dist/shared/InteractiveVideo.svelte +1 -2
- package/dist/shared/InteractiveVideo.svelte.d.ts +12 -10
- package/dist/shared/Player.svelte +5 -10
- package/dist/shared/Player.svelte.d.ts +12 -10
- package/dist/shared/Video.svelte +6 -22
- package/dist/shared/Video.svelte.d.ts +2 -0
- package/dist/shared/VideoControls.svelte +2 -3
- package/dist/shared/VideoControls.svelte.d.ts +10 -8
- package/dist/shared/VideoPreview.svelte +3 -4
- package/dist/shared/VideoPreview.svelte.d.ts +8 -6
- package/dist/shared/VideoTimeline.svelte +3 -6
- package/dist/shared/VideoTimeline.svelte.d.ts +2 -0
- package/package.json +7 -8
- package/shared/Video.svelte +1 -25
- package/shared/VideoPreview.svelte +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @gradio/video
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#11858](https://github.com/gradio-app/gradio/pull/11858) [`3f8ea13`](https://github.com/gradio-app/gradio/commit/3f8ea13a8ca92abf0ad34392e403a449fda3c6c2) - remove lite. Thanks @pngwn!
|
|
8
|
+
|
|
9
|
+
### Fixes
|
|
10
|
+
|
|
11
|
+
- [#11784](https://github.com/gradio-app/gradio/pull/11784) [`d9dd3f5`](https://github.com/gradio-app/gradio/commit/d9dd3f54b7fb34cf7118e549d39fc63937ca3489) - Add "hidden" option to component's `visible` kwarg to render but visually hide the component. Thanks @pngwn!
|
|
12
|
+
|
|
13
|
+
### Dependency updates
|
|
14
|
+
|
|
15
|
+
- @gradio/statustracker@0.11.1
|
|
16
|
+
- @gradio/atoms@0.18.0
|
|
17
|
+
- @gradio/client@1.19.0
|
|
18
|
+
- @gradio/upload@0.17.0
|
|
19
|
+
- @gradio/image@0.23.0
|
|
20
|
+
|
|
21
|
+
## 0.15.1
|
|
22
|
+
|
|
23
|
+
### Dependency updates
|
|
24
|
+
|
|
25
|
+
- @gradio/client@1.18.0
|
|
26
|
+
- @gradio/icons@0.14.0
|
|
27
|
+
- @gradio/atoms@0.17.0
|
|
28
|
+
- @gradio/statustracker@0.11.0
|
|
29
|
+
- @gradio/upload@0.16.17
|
|
30
|
+
- @gradio/image@0.22.18
|
|
31
|
+
|
|
32
|
+
## 0.15.0
|
|
33
|
+
|
|
34
|
+
### Dependency updates
|
|
35
|
+
|
|
36
|
+
- @gradio/statustracker@0.10.18
|
|
37
|
+
|
|
38
|
+
## 0.15.0
|
|
39
|
+
|
|
40
|
+
### Dependency updates
|
|
41
|
+
|
|
42
|
+
- @gradio/icons@0.13.1
|
|
43
|
+
- @gradio/upload@0.16.16
|
|
44
|
+
|
|
3
45
|
## 0.15.0
|
|
4
46
|
|
|
5
47
|
### Features
|
package/Index.svelte
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import type { WebcamOptions } from "./shared/utils";
|
|
13
13
|
export let elem_id = "";
|
|
14
14
|
export let elem_classes: string[] = [];
|
|
15
|
-
export let visible = true;
|
|
15
|
+
export let visible: boolean | "hidden" = true;
|
|
16
16
|
export let value: { video: FileData; subtitles: FileData | null } | null =
|
|
17
17
|
null;
|
|
18
18
|
let old_value: { video: FileData; subtitles: FileData | null } | null = null;
|
package/dist/Example.svelte.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type FileData } from "@gradio/client";
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
type: "gallery" | "table";
|
|
6
|
-
selected?: boolean
|
|
6
|
+
selected?: boolean;
|
|
7
7
|
value: {
|
|
8
8
|
video: FileData;
|
|
9
9
|
subtitles: FileData | null;
|
|
@@ -14,6 +14,8 @@ declare const __propDef: {
|
|
|
14
14
|
[evt: string]: CustomEvent<any>;
|
|
15
15
|
};
|
|
16
16
|
slots: {};
|
|
17
|
+
exports?: {} | undefined;
|
|
18
|
+
bindings?: string | undefined;
|
|
17
19
|
};
|
|
18
20
|
export type ExampleProps = typeof __propDef.props;
|
|
19
21
|
export type ExampleEvents = typeof __propDef.events;
|
package/dist/Index.svelte
CHANGED
|
@@ -29,26 +29,23 @@ export let include_audio;
|
|
|
29
29
|
export let loop = false;
|
|
30
30
|
export let input_ready;
|
|
31
31
|
let uploading = false;
|
|
32
|
-
$:
|
|
33
|
-
input_ready = !uploading;
|
|
32
|
+
$: input_ready = !uploading;
|
|
34
33
|
let _video = null;
|
|
35
34
|
let _subtitle = null;
|
|
36
35
|
let active_source;
|
|
37
36
|
let initial_value = value;
|
|
38
|
-
$:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
37
|
+
$: if (value && initial_value === null) {
|
|
38
|
+
initial_value = value;
|
|
39
|
+
}
|
|
42
40
|
const handle_reset_value = () => {
|
|
43
41
|
if (initial_value === null || value === initial_value) {
|
|
44
42
|
return;
|
|
45
43
|
}
|
|
46
44
|
value = initial_value;
|
|
47
45
|
};
|
|
48
|
-
$:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
46
|
+
$: if (sources && !active_source) {
|
|
47
|
+
active_source = sources[0];
|
|
48
|
+
}
|
|
52
49
|
$: {
|
|
53
50
|
if (value != null) {
|
|
54
51
|
_video = value.video;
|
package/dist/Index.svelte.d.ts
CHANGED
|
@@ -5,13 +5,13 @@ import type { LoadingStatus } from "@gradio/statustracker";
|
|
|
5
5
|
import type { WebcamOptions } from "./shared/utils";
|
|
6
6
|
declare const __propDef: {
|
|
7
7
|
props: {
|
|
8
|
-
elem_id?: string
|
|
9
|
-
elem_classes?: string[]
|
|
10
|
-
visible?: boolean |
|
|
11
|
-
value?:
|
|
8
|
+
elem_id?: string;
|
|
9
|
+
elem_classes?: string[];
|
|
10
|
+
visible?: boolean | "hidden";
|
|
11
|
+
value?: {
|
|
12
12
|
video: FileData;
|
|
13
13
|
subtitles: FileData | null;
|
|
14
|
-
} | null
|
|
14
|
+
} | null;
|
|
15
15
|
label: string;
|
|
16
16
|
sources: ["webcam"] | ["upload"] | ["webcam", "upload"] | ["upload", "webcam"];
|
|
17
17
|
root: string;
|
|
@@ -19,11 +19,11 @@ declare const __propDef: {
|
|
|
19
19
|
loading_status: LoadingStatus;
|
|
20
20
|
height: number | undefined;
|
|
21
21
|
width: number | undefined;
|
|
22
|
-
container?: boolean
|
|
23
|
-
scale?:
|
|
22
|
+
container?: boolean;
|
|
23
|
+
scale?: number | null;
|
|
24
24
|
min_width?: number | undefined;
|
|
25
|
-
autoplay?: boolean
|
|
26
|
-
show_share_button?: boolean
|
|
25
|
+
autoplay?: boolean;
|
|
26
|
+
show_share_button?: boolean;
|
|
27
27
|
show_download_button: boolean;
|
|
28
28
|
gradio: Gradio<{
|
|
29
29
|
change: never;
|
|
@@ -43,13 +43,15 @@ declare const __propDef: {
|
|
|
43
43
|
interactive: boolean;
|
|
44
44
|
webcam_options: WebcamOptions;
|
|
45
45
|
include_audio: boolean;
|
|
46
|
-
loop?: boolean
|
|
46
|
+
loop?: boolean;
|
|
47
47
|
input_ready: boolean;
|
|
48
48
|
};
|
|
49
49
|
events: {
|
|
50
50
|
[evt: string]: CustomEvent<any>;
|
|
51
51
|
};
|
|
52
52
|
slots: {};
|
|
53
|
+
exports?: {} | undefined;
|
|
54
|
+
bindings?: string | undefined;
|
|
53
55
|
};
|
|
54
56
|
export type IndexProps = typeof __propDef.props;
|
|
55
57
|
export type IndexEvents = typeof __propDef.events;
|
|
@@ -61,9 +63,9 @@ export default class Index extends SvelteComponent<IndexProps, IndexEvents, Inde
|
|
|
61
63
|
get elem_classes(): string[] | undefined;
|
|
62
64
|
/**accessor*/
|
|
63
65
|
set elem_classes(_: string[] | undefined);
|
|
64
|
-
get visible(): boolean | undefined;
|
|
66
|
+
get visible(): boolean | "hidden" | undefined;
|
|
65
67
|
/**accessor*/
|
|
66
|
-
set visible(_: boolean | undefined);
|
|
68
|
+
set visible(_: boolean | "hidden" | undefined);
|
|
67
69
|
get value(): {
|
|
68
70
|
video: FileData;
|
|
69
71
|
subtitles: FileData | null;
|
|
@@ -4,24 +4,24 @@ import type { WebcamOptions } from "./utils";
|
|
|
4
4
|
import type { I18nFormatter } from "@gradio/utils";
|
|
5
5
|
declare const __propDef: {
|
|
6
6
|
props: {
|
|
7
|
-
value?:
|
|
8
|
-
subtitle?:
|
|
9
|
-
sources?:
|
|
7
|
+
value?: FileData | null;
|
|
8
|
+
subtitle?: FileData | null;
|
|
9
|
+
sources?: ["webcam"] | ["upload"] | ["webcam", "upload"] | ["upload", "webcam"];
|
|
10
10
|
label?: string | undefined;
|
|
11
|
-
show_download_button?: boolean
|
|
12
|
-
show_label?: boolean
|
|
11
|
+
show_download_button?: boolean;
|
|
12
|
+
show_label?: boolean;
|
|
13
13
|
webcam_options: WebcamOptions;
|
|
14
14
|
include_audio: boolean;
|
|
15
15
|
autoplay: boolean;
|
|
16
16
|
root: string;
|
|
17
17
|
i18n: I18nFormatter;
|
|
18
|
-
active_source?:
|
|
19
|
-
handle_reset_value?: (
|
|
20
|
-
max_file_size?:
|
|
18
|
+
active_source?: "webcam" | "upload";
|
|
19
|
+
handle_reset_value?: () => void;
|
|
20
|
+
max_file_size?: number | null;
|
|
21
21
|
upload: Client["upload"];
|
|
22
22
|
stream_handler: Client["stream"];
|
|
23
23
|
loop: boolean;
|
|
24
|
-
uploading?: boolean
|
|
24
|
+
uploading?: boolean;
|
|
25
25
|
};
|
|
26
26
|
events: {
|
|
27
27
|
error: CustomEvent<any>;
|
|
@@ -31,7 +31,7 @@ declare const __propDef: {
|
|
|
31
31
|
pause: CustomEvent<any>;
|
|
32
32
|
stop: CustomEvent<undefined>;
|
|
33
33
|
end: CustomEvent<any>;
|
|
34
|
-
change: CustomEvent<
|
|
34
|
+
change: CustomEvent<any>;
|
|
35
35
|
clear?: CustomEvent<undefined> | undefined;
|
|
36
36
|
drag: CustomEvent<boolean>;
|
|
37
37
|
upload: CustomEvent<FileData>;
|
|
@@ -41,6 +41,8 @@ declare const __propDef: {
|
|
|
41
41
|
slots: {
|
|
42
42
|
default: {};
|
|
43
43
|
};
|
|
44
|
+
exports?: {} | undefined;
|
|
45
|
+
bindings?: string | undefined;
|
|
44
46
|
};
|
|
45
47
|
export type InteractiveVideoProps = typeof __propDef.props;
|
|
46
48
|
export type InteractiveVideoEvents = typeof __propDef.events;
|
|
@@ -31,14 +31,12 @@ let paused = true;
|
|
|
31
31
|
let video;
|
|
32
32
|
let processingVideo = false;
|
|
33
33
|
function handleMove(e) {
|
|
34
|
-
if (!duration)
|
|
35
|
-
return;
|
|
34
|
+
if (!duration) return;
|
|
36
35
|
if (e.type === "click") {
|
|
37
36
|
handle_click(e);
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
|
-
if (e.type !== "touchmove" && !(e.buttons & 1))
|
|
41
|
-
return;
|
|
39
|
+
if (e.type !== "touchmove" && !(e.buttons & 1)) return;
|
|
42
40
|
const clientX = e.type === "touchmove" ? e.touches[0].clientX : e.clientX;
|
|
43
41
|
const { left, right } = e.currentTarget.getBoundingClientRect();
|
|
44
42
|
time = duration * (clientX - left) / (right - left);
|
|
@@ -48,8 +46,7 @@ async function play_pause() {
|
|
|
48
46
|
const isPlaying = video.currentTime > 0 && !video.paused && !video.ended && video.readyState > video.HAVE_CURRENT_DATA;
|
|
49
47
|
if (!isPlaying) {
|
|
50
48
|
await video.play();
|
|
51
|
-
} else
|
|
52
|
-
video.pause();
|
|
49
|
+
} else video.pause();
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
function handle_click(e) {
|
|
@@ -69,10 +66,8 @@ const handle_trim_video = async (videoBlob) => {
|
|
|
69
66
|
function open_full_screen() {
|
|
70
67
|
video.requestFullscreen();
|
|
71
68
|
}
|
|
72
|
-
$:
|
|
73
|
-
|
|
74
|
-
$:
|
|
75
|
-
duration = duration || 0;
|
|
69
|
+
$: time = time || 0;
|
|
70
|
+
$: duration = duration || 0;
|
|
76
71
|
</script>
|
|
77
72
|
|
|
78
73
|
<div class="wrap">
|
|
@@ -3,23 +3,23 @@ import type { FileData, Client } from "@gradio/client";
|
|
|
3
3
|
import type { I18nFormatter } from "@gradio/utils";
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
|
-
root?: string
|
|
6
|
+
root?: string;
|
|
7
7
|
src: string;
|
|
8
|
-
subtitle?:
|
|
8
|
+
subtitle?: string | null;
|
|
9
9
|
mirror: boolean;
|
|
10
10
|
autoplay: boolean;
|
|
11
11
|
loop: boolean;
|
|
12
|
-
label?: string
|
|
13
|
-
interactive?: boolean
|
|
14
|
-
handle_change?: (
|
|
15
|
-
handle_reset_value?: (
|
|
12
|
+
label?: string;
|
|
13
|
+
interactive?: boolean;
|
|
14
|
+
handle_change?: (video: FileData) => void;
|
|
15
|
+
handle_reset_value?: () => void;
|
|
16
16
|
upload: Client["upload"];
|
|
17
17
|
is_stream: boolean | undefined;
|
|
18
18
|
i18n: I18nFormatter;
|
|
19
|
-
show_download_button?: boolean
|
|
20
|
-
value?:
|
|
21
|
-
handle_clear?: (
|
|
22
|
-
has_change_history?: boolean
|
|
19
|
+
show_download_button?: boolean;
|
|
20
|
+
value?: FileData | null;
|
|
21
|
+
handle_clear?: () => void;
|
|
22
|
+
has_change_history?: boolean;
|
|
23
23
|
};
|
|
24
24
|
events: {
|
|
25
25
|
play: CustomEvent<any>;
|
|
@@ -35,6 +35,8 @@ declare const __propDef: {
|
|
|
35
35
|
[evt: string]: CustomEvent<any>;
|
|
36
36
|
};
|
|
37
37
|
slots: {};
|
|
38
|
+
exports?: {} | undefined;
|
|
39
|
+
bindings?: string | undefined;
|
|
38
40
|
};
|
|
39
41
|
export type PlayerProps = typeof __propDef.props;
|
|
40
42
|
export type PlayerEvents = typeof __propDef.events;
|
package/dist/shared/Video.svelte
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script>import { createEventDispatcher } from "svelte";
|
|
2
2
|
import { loaded } from "./utils";
|
|
3
|
-
import { resolve_wasm_src } from "@gradio/wasm/svelte";
|
|
4
3
|
import Hls from "hls.js";
|
|
5
4
|
export let src = void 0;
|
|
6
5
|
export let muted = void 0;
|
|
@@ -15,23 +14,10 @@ export let node = void 0;
|
|
|
15
14
|
export let loop;
|
|
16
15
|
export let is_stream;
|
|
17
16
|
export let processingVideo = false;
|
|
18
|
-
let resolved_src;
|
|
19
17
|
let stream_active = false;
|
|
20
|
-
let latest_src;
|
|
21
|
-
$: {
|
|
22
|
-
resolved_src = src;
|
|
23
|
-
latest_src = src;
|
|
24
|
-
const resolving_src = src;
|
|
25
|
-
resolve_wasm_src(resolving_src).then((s) => {
|
|
26
|
-
if (latest_src === resolving_src) {
|
|
27
|
-
resolved_src = s;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
18
|
const dispatch = createEventDispatcher();
|
|
32
19
|
function load_stream(src2, is_stream2, node2) {
|
|
33
|
-
if (!src2 || !is_stream2)
|
|
34
|
-
return;
|
|
20
|
+
if (!src2 || !is_stream2) return;
|
|
35
21
|
if (Hls.isSupported() && !stream_active) {
|
|
36
22
|
const hls = new Hls({
|
|
37
23
|
maxBufferLength: 1,
|
|
@@ -70,12 +56,10 @@ function load_stream(src2, is_stream2, node2) {
|
|
|
70
56
|
stream_active = true;
|
|
71
57
|
}
|
|
72
58
|
}
|
|
73
|
-
$:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
load_stream(src, is_stream, node);
|
|
78
|
-
}
|
|
59
|
+
$: src, stream_active = false;
|
|
60
|
+
$: if (node && src && is_stream) {
|
|
61
|
+
load_stream(src, is_stream, node);
|
|
62
|
+
}
|
|
79
63
|
</script>
|
|
80
64
|
|
|
81
65
|
<!--
|
|
@@ -91,7 +75,7 @@ Then, even when `controls` is false, the compiled DOM would be `<video controls=
|
|
|
91
75
|
</span>
|
|
92
76
|
</div>
|
|
93
77
|
<video
|
|
94
|
-
src
|
|
78
|
+
{src}
|
|
95
79
|
{muted}
|
|
96
80
|
{playsinline}
|
|
97
81
|
{preload}
|
|
@@ -24,9 +24,8 @@ let ffmpeg;
|
|
|
24
24
|
onMount(async () => {
|
|
25
25
|
ffmpeg = await loadFfmpeg();
|
|
26
26
|
});
|
|
27
|
-
$:
|
|
28
|
-
|
|
29
|
-
trimmedDuration = videoElement.duration;
|
|
27
|
+
$: if (mode === "edit" && trimmedDuration === null && videoElement)
|
|
28
|
+
trimmedDuration = videoElement.duration;
|
|
30
29
|
let trimmedDuration = null;
|
|
31
30
|
let dragStart = 0;
|
|
32
31
|
let dragEnd = 0;
|
|
@@ -3,22 +3,24 @@ import type { FileData } from "@gradio/client";
|
|
|
3
3
|
declare const __propDef: {
|
|
4
4
|
props: {
|
|
5
5
|
videoElement: HTMLVideoElement;
|
|
6
|
-
showRedo?: boolean
|
|
7
|
-
interactive?: boolean
|
|
8
|
-
mode?: string
|
|
6
|
+
showRedo?: boolean;
|
|
7
|
+
interactive?: boolean;
|
|
8
|
+
mode?: string;
|
|
9
9
|
handle_reset_value: () => void;
|
|
10
10
|
handle_trim_video: (videoBlob: Blob) => void;
|
|
11
|
-
processingVideo?: boolean
|
|
11
|
+
processingVideo?: boolean;
|
|
12
12
|
i18n: (key: string) => string;
|
|
13
|
-
value?:
|
|
14
|
-
show_download_button?: boolean
|
|
15
|
-
handle_clear?: (
|
|
16
|
-
has_change_history?: boolean
|
|
13
|
+
value?: FileData | null;
|
|
14
|
+
show_download_button?: boolean;
|
|
15
|
+
handle_clear?: () => void;
|
|
16
|
+
has_change_history?: boolean;
|
|
17
17
|
};
|
|
18
18
|
events: {
|
|
19
19
|
[evt: string]: CustomEvent<any>;
|
|
20
20
|
};
|
|
21
21
|
slots: {};
|
|
22
|
+
exports?: {} | undefined;
|
|
23
|
+
bindings?: string | undefined;
|
|
22
24
|
};
|
|
23
25
|
export type VideoControlsProps = typeof __propDef.props;
|
|
24
26
|
export type VideoControlsEvents = typeof __propDef.events;
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
Empty,
|
|
5
5
|
IconButton,
|
|
6
6
|
ShareButton,
|
|
7
|
-
IconButtonWrapper
|
|
7
|
+
IconButtonWrapper,
|
|
8
|
+
DownloadLink
|
|
8
9
|
} from "@gradio/atoms";
|
|
9
10
|
import { Video, Download } from "@gradio/icons";
|
|
10
11
|
import { uploadToHuggingFace } from "@gradio/utils";
|
|
11
|
-
import { DownloadLink } from "@gradio/wasm/svelte";
|
|
12
12
|
import Player from "./Player.svelte";
|
|
13
13
|
export let value = null;
|
|
14
14
|
export let subtitle = null;
|
|
@@ -24,8 +24,7 @@ export let display_icon_button_wrapper_top_corner = false;
|
|
|
24
24
|
let old_value = null;
|
|
25
25
|
let old_subtitle = null;
|
|
26
26
|
const dispatch = createEventDispatcher();
|
|
27
|
-
$:
|
|
28
|
-
value && dispatch("change", value);
|
|
27
|
+
$: value && dispatch("change", value);
|
|
29
28
|
afterUpdate(async () => {
|
|
30
29
|
if (value !== old_value && subtitle !== old_subtitle && old_subtitle !== null) {
|
|
31
30
|
old_value = value;
|
|
@@ -3,17 +3,17 @@ import type { FileData, Client } from "@gradio/client";
|
|
|
3
3
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
4
4
|
declare const __propDef: {
|
|
5
5
|
props: {
|
|
6
|
-
value?:
|
|
7
|
-
subtitle?:
|
|
6
|
+
value?: FileData | null;
|
|
7
|
+
subtitle?: FileData | null;
|
|
8
8
|
label?: string | undefined;
|
|
9
|
-
show_label?: boolean
|
|
9
|
+
show_label?: boolean;
|
|
10
10
|
autoplay: boolean;
|
|
11
|
-
show_share_button?: boolean
|
|
12
|
-
show_download_button?: boolean
|
|
11
|
+
show_share_button?: boolean;
|
|
12
|
+
show_download_button?: boolean;
|
|
13
13
|
loop: boolean;
|
|
14
14
|
i18n: I18nFormatter;
|
|
15
15
|
upload: Client["upload"];
|
|
16
|
-
display_icon_button_wrapper_top_corner?: boolean
|
|
16
|
+
display_icon_button_wrapper_top_corner?: boolean;
|
|
17
17
|
};
|
|
18
18
|
events: {
|
|
19
19
|
play: CustomEvent<any>;
|
|
@@ -28,6 +28,8 @@ declare const __propDef: {
|
|
|
28
28
|
[evt: string]: CustomEvent<any>;
|
|
29
29
|
};
|
|
30
30
|
slots: {};
|
|
31
|
+
exports?: {} | undefined;
|
|
32
|
+
bindings?: string | undefined;
|
|
31
33
|
};
|
|
32
34
|
export type VideoPreviewProps = typeof __propDef.props;
|
|
33
35
|
export type VideoPreviewEvents = typeof __propDef.events;
|
|
@@ -14,16 +14,14 @@ let dragging = null;
|
|
|
14
14
|
const startDragging = (side) => {
|
|
15
15
|
dragging = side;
|
|
16
16
|
};
|
|
17
|
-
$:
|
|
18
|
-
loadingTimeline = thumbnails.length !== numberOfThumbnails;
|
|
17
|
+
$: loadingTimeline = thumbnails.length !== numberOfThumbnails;
|
|
19
18
|
const stopDragging = () => {
|
|
20
19
|
dragging = null;
|
|
21
20
|
};
|
|
22
21
|
const drag = (event, distance) => {
|
|
23
22
|
if (dragging) {
|
|
24
23
|
const timeline = document.getElementById("timeline");
|
|
25
|
-
if (!timeline)
|
|
26
|
-
return;
|
|
24
|
+
if (!timeline) return;
|
|
27
25
|
const rect = timeline.getBoundingClientRect();
|
|
28
26
|
let newPercentage = (event.clientX - rect.left) / rect.width * 100;
|
|
29
27
|
if (distance) {
|
|
@@ -63,8 +61,7 @@ const moveHandle = (e) => {
|
|
|
63
61
|
const generateThumbnail = () => {
|
|
64
62
|
const canvas = document.createElement("canvas");
|
|
65
63
|
const ctx = canvas.getContext("2d");
|
|
66
|
-
if (!ctx)
|
|
67
|
-
return;
|
|
64
|
+
if (!ctx) return;
|
|
68
65
|
canvas.width = videoElement.videoWidth;
|
|
69
66
|
canvas.height = videoElement.videoHeight;
|
|
70
67
|
ctx.drawImage(videoElement, 0, 0, canvas.width, canvas.height);
|
|
@@ -11,6 +11,8 @@ declare const __propDef: {
|
|
|
11
11
|
[evt: string]: CustomEvent<any>;
|
|
12
12
|
};
|
|
13
13
|
slots: {};
|
|
14
|
+
exports?: {} | undefined;
|
|
15
|
+
bindings?: string | undefined;
|
|
14
16
|
};
|
|
15
17
|
export type VideoTimelineProps = typeof __propDef.props;
|
|
16
18
|
export type VideoTimelineEvents = typeof __propDef.events;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/video",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -11,14 +11,13 @@
|
|
|
11
11
|
"@ffmpeg/util": "^0.12.1",
|
|
12
12
|
"hls.js": "^1.5.13",
|
|
13
13
|
"mrmime": "^2.0.0",
|
|
14
|
-
"@gradio/
|
|
15
|
-
"@gradio/
|
|
16
|
-
"@gradio/
|
|
17
|
-
"@gradio/
|
|
18
|
-
"@gradio/
|
|
14
|
+
"@gradio/atoms": "^0.18.0",
|
|
15
|
+
"@gradio/icons": "^0.14.0",
|
|
16
|
+
"@gradio/client": "^1.19.0",
|
|
17
|
+
"@gradio/upload": "^0.17.0",
|
|
18
|
+
"@gradio/image": "^0.23.0",
|
|
19
19
|
"@gradio/utils": "^0.10.2",
|
|
20
|
-
"@gradio/
|
|
21
|
-
"@gradio/image": "^0.22.17"
|
|
20
|
+
"@gradio/statustracker": "^0.11.1"
|
|
22
21
|
},
|
|
23
22
|
"devDependencies": {
|
|
24
23
|
"@gradio/preview": "^0.14.0"
|
package/shared/Video.svelte
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
import { createEventDispatcher } from "svelte";
|
|
4
4
|
import { loaded } from "./utils";
|
|
5
5
|
|
|
6
|
-
import { resolve_wasm_src } from "@gradio/wasm/svelte";
|
|
7
|
-
|
|
8
6
|
import Hls from "hls.js";
|
|
9
7
|
|
|
10
8
|
export let src: HTMLVideoAttributes["src"] = undefined;
|
|
@@ -25,30 +23,8 @@
|
|
|
25
23
|
|
|
26
24
|
export let processingVideo = false;
|
|
27
25
|
|
|
28
|
-
let resolved_src: typeof src;
|
|
29
26
|
let stream_active = false;
|
|
30
27
|
|
|
31
|
-
// The `src` prop can be updated before the Promise from `resolve_wasm_src` is resolved.
|
|
32
|
-
// In such a case, the resolved value for the old `src` has to be discarded,
|
|
33
|
-
// This variable `latest_src` is used to pick up only the value resolved for the latest `src` prop.
|
|
34
|
-
let latest_src: typeof src;
|
|
35
|
-
$: {
|
|
36
|
-
// In normal (non-Wasm) Gradio, the `<img>` element should be rendered with the passed `src` props immediately
|
|
37
|
-
// without waiting for `resolve_wasm_src()` to resolve.
|
|
38
|
-
// If it waits, a blank element is displayed until the async task finishes
|
|
39
|
-
// and it leads to undesirable flickering.
|
|
40
|
-
// So set `src` to `resolved_src` here.
|
|
41
|
-
resolved_src = src;
|
|
42
|
-
|
|
43
|
-
latest_src = src;
|
|
44
|
-
const resolving_src = src;
|
|
45
|
-
resolve_wasm_src(resolving_src).then((s) => {
|
|
46
|
-
if (latest_src === resolving_src) {
|
|
47
|
-
resolved_src = s;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
28
|
const dispatch = createEventDispatcher();
|
|
53
29
|
|
|
54
30
|
function load_stream(
|
|
@@ -114,7 +90,7 @@ Then, even when `controls` is false, the compiled DOM would be `<video controls=
|
|
|
114
90
|
</span>
|
|
115
91
|
</div>
|
|
116
92
|
<video
|
|
117
|
-
src
|
|
93
|
+
{src}
|
|
118
94
|
{muted}
|
|
119
95
|
{playsinline}
|
|
120
96
|
{preload}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
Empty,
|
|
6
6
|
IconButton,
|
|
7
7
|
ShareButton,
|
|
8
|
-
IconButtonWrapper
|
|
8
|
+
IconButtonWrapper,
|
|
9
|
+
DownloadLink
|
|
9
10
|
} from "@gradio/atoms";
|
|
10
11
|
import type { FileData, Client } from "@gradio/client";
|
|
11
12
|
import { Video, Download } from "@gradio/icons";
|
|
12
13
|
import { uploadToHuggingFace } from "@gradio/utils";
|
|
13
|
-
import { DownloadLink } from "@gradio/wasm/svelte";
|
|
14
14
|
|
|
15
15
|
import Player from "./Player.svelte";
|
|
16
16
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|