@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
|
@@ -1,52 +1,62 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { FileData, Client } from "@gradio/client";
|
|
3
2
|
import type { WebcamOptions } from "./utils";
|
|
4
3
|
import type { I18nFormatter } from "@gradio/utils";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
autoplay: boolean;
|
|
16
|
-
root: string;
|
|
17
|
-
i18n: I18nFormatter;
|
|
18
|
-
active_source?: "webcam" | "upload";
|
|
19
|
-
handle_reset_value?: () => void;
|
|
20
|
-
max_file_size?: number | null;
|
|
21
|
-
upload: Client["upload"];
|
|
22
|
-
stream_handler: Client["stream"];
|
|
23
|
-
loop: boolean;
|
|
24
|
-
uploading?: boolean;
|
|
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> {
|
|
5
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
6
|
+
$$bindings?: Bindings;
|
|
7
|
+
} & Exports;
|
|
8
|
+
(internal: unknown, props: Props & {
|
|
9
|
+
$$events?: Events;
|
|
10
|
+
$$slots?: Slots;
|
|
11
|
+
}): Exports & {
|
|
12
|
+
$set?: any;
|
|
13
|
+
$on?: any;
|
|
25
14
|
};
|
|
26
|
-
|
|
27
|
-
error: CustomEvent<any>;
|
|
28
|
-
start_recording: CustomEvent<any>;
|
|
29
|
-
stop_recording: CustomEvent<any>;
|
|
30
|
-
play: CustomEvent<any>;
|
|
31
|
-
pause: CustomEvent<any>;
|
|
32
|
-
stop: CustomEvent<undefined>;
|
|
33
|
-
end: CustomEvent<any>;
|
|
34
|
-
change: CustomEvent<any>;
|
|
35
|
-
clear?: CustomEvent<undefined> | undefined;
|
|
36
|
-
drag: CustomEvent<boolean>;
|
|
37
|
-
upload: CustomEvent<FileData>;
|
|
38
|
-
} & {
|
|
39
|
-
[evt: string]: CustomEvent<any>;
|
|
40
|
-
};
|
|
41
|
-
slots: {
|
|
42
|
-
default: {};
|
|
43
|
-
};
|
|
44
|
-
exports?: {} | undefined;
|
|
45
|
-
bindings?: string | undefined;
|
|
46
|
-
};
|
|
47
|
-
export type InteractiveVideoProps = typeof __propDef.props;
|
|
48
|
-
export type InteractiveVideoEvents = typeof __propDef.events;
|
|
49
|
-
export type InteractiveVideoSlots = typeof __propDef.slots;
|
|
50
|
-
export default class InteractiveVideo extends SvelteComponent<InteractiveVideoProps, InteractiveVideoEvents, InteractiveVideoSlots> {
|
|
15
|
+
z_$$bindings?: Bindings;
|
|
51
16
|
}
|
|
52
|
-
|
|
17
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
18
|
+
default: any;
|
|
19
|
+
} ? Props extends Record<string, never> ? any : {
|
|
20
|
+
children?: any;
|
|
21
|
+
} : {});
|
|
22
|
+
declare const InteractiveVideo: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
23
|
+
value?: FileData | null;
|
|
24
|
+
subtitle?: FileData | null;
|
|
25
|
+
sources?: ["webcam"] | ["upload"] | ["webcam", "upload"] | ["upload", "webcam"];
|
|
26
|
+
label?: string | undefined;
|
|
27
|
+
show_download_button?: boolean;
|
|
28
|
+
show_label?: boolean;
|
|
29
|
+
webcam_options: WebcamOptions;
|
|
30
|
+
include_audio: boolean;
|
|
31
|
+
autoplay: boolean;
|
|
32
|
+
root: string;
|
|
33
|
+
i18n: I18nFormatter;
|
|
34
|
+
active_source?: "webcam" | "upload";
|
|
35
|
+
handle_reset_value?: () => void;
|
|
36
|
+
max_file_size?: number | null;
|
|
37
|
+
upload: Client["upload"];
|
|
38
|
+
stream_handler: Client["stream"];
|
|
39
|
+
loop: boolean;
|
|
40
|
+
uploading?: boolean;
|
|
41
|
+
upload_promise?: Promise<any> | null;
|
|
42
|
+
}, {
|
|
43
|
+
default: {};
|
|
44
|
+
}>, {
|
|
45
|
+
error: CustomEvent<any>;
|
|
46
|
+
start_recording: CustomEvent<any>;
|
|
47
|
+
stop_recording: CustomEvent<any>;
|
|
48
|
+
play: CustomEvent<any>;
|
|
49
|
+
pause: CustomEvent<any>;
|
|
50
|
+
stop: CustomEvent<undefined>;
|
|
51
|
+
end: CustomEvent<any>;
|
|
52
|
+
change: CustomEvent<FileData | null>;
|
|
53
|
+
clear?: CustomEvent<undefined> | undefined;
|
|
54
|
+
drag: CustomEvent<boolean>;
|
|
55
|
+
upload: CustomEvent<FileData>;
|
|
56
|
+
} & {
|
|
57
|
+
[evt: string]: CustomEvent<any>;
|
|
58
|
+
}, {
|
|
59
|
+
default: {};
|
|
60
|
+
}, {}, string>;
|
|
61
|
+
type InteractiveVideo = InstanceType<typeof InteractiveVideo>;
|
|
62
|
+
export default InteractiveVideo;
|
|
@@ -1,73 +1,105 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
export let
|
|
16
|
-
|
|
17
|
-
export let
|
|
18
|
-
|
|
19
|
-
export let
|
|
20
|
-
export let
|
|
21
|
-
export let
|
|
22
|
-
export let
|
|
23
|
-
export let
|
|
24
|
-
export let
|
|
25
|
-
|
|
26
|
-
export let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
3
|
+
import { Play, Pause, Maximize, Undo } from "@gradio/icons";
|
|
4
|
+
import Video from "./Video.svelte";
|
|
5
|
+
import VideoControls from "./VideoControls.svelte";
|
|
6
|
+
import type { FileData, Client } from "@gradio/client";
|
|
7
|
+
import { prepare_files } from "@gradio/client";
|
|
8
|
+
import { format_time } from "@gradio/utils";
|
|
9
|
+
import type { I18nFormatter } from "@gradio/utils";
|
|
10
|
+
|
|
11
|
+
export let root = "";
|
|
12
|
+
export let src: string;
|
|
13
|
+
export let subtitle: string | null = null;
|
|
14
|
+
export let mirror: boolean;
|
|
15
|
+
export let autoplay: boolean;
|
|
16
|
+
export let loop: boolean;
|
|
17
|
+
export let label = "test";
|
|
18
|
+
export let interactive = false;
|
|
19
|
+
export let handle_change: (video: FileData) => void = () => {};
|
|
20
|
+
export let handle_reset_value: () => void = () => {};
|
|
21
|
+
export let upload: Client["upload"];
|
|
22
|
+
export let is_stream: boolean | undefined;
|
|
23
|
+
export let i18n: I18nFormatter;
|
|
24
|
+
export let show_download_button = false;
|
|
25
|
+
export let value: FileData | null = null;
|
|
26
|
+
export let handle_clear: () => void = () => {};
|
|
27
|
+
export let has_change_history = false;
|
|
28
|
+
|
|
29
|
+
const dispatch = createEventDispatcher<{
|
|
30
|
+
play: undefined;
|
|
31
|
+
pause: undefined;
|
|
32
|
+
stop: undefined;
|
|
33
|
+
end: undefined;
|
|
34
|
+
clear: undefined;
|
|
35
|
+
}>();
|
|
36
|
+
|
|
37
|
+
let time = 0;
|
|
38
|
+
let duration: number;
|
|
39
|
+
let paused = true;
|
|
40
|
+
let video: HTMLVideoElement;
|
|
41
|
+
let processingVideo = false;
|
|
42
|
+
|
|
43
|
+
function handleMove(e: TouchEvent | MouseEvent): void {
|
|
44
|
+
if (!duration) return;
|
|
45
|
+
|
|
46
|
+
if (e.type === "click") {
|
|
47
|
+
handle_click(e as MouseEvent);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (e.type !== "touchmove" && !((e as MouseEvent).buttons & 1)) return;
|
|
52
|
+
|
|
53
|
+
const clientX =
|
|
54
|
+
e.type === "touchmove"
|
|
55
|
+
? (e as TouchEvent).touches[0].clientX
|
|
56
|
+
: (e as MouseEvent).clientX;
|
|
57
|
+
const { left, right } = (
|
|
58
|
+
e.currentTarget as HTMLProgressElement
|
|
59
|
+
).getBoundingClientRect();
|
|
60
|
+
time = (duration * (clientX - left)) / (right - left);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function play_pause(): Promise<void> {
|
|
64
|
+
if (document.fullscreenElement != video) {
|
|
65
|
+
const isPlaying =
|
|
66
|
+
video.currentTime > 0 &&
|
|
67
|
+
!video.paused &&
|
|
68
|
+
!video.ended &&
|
|
69
|
+
video.readyState > video.HAVE_CURRENT_DATA;
|
|
70
|
+
|
|
71
|
+
if (!isPlaying) {
|
|
72
|
+
await video.play();
|
|
73
|
+
} else video.pause();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function handle_click(e: MouseEvent): void {
|
|
78
|
+
const { left, right } = (
|
|
79
|
+
e.currentTarget as HTMLProgressElement
|
|
80
|
+
).getBoundingClientRect();
|
|
81
|
+
time = (duration * (e.clientX - left)) / (right - left);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function handle_end(): void {
|
|
85
|
+
dispatch("stop");
|
|
86
|
+
dispatch("end");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const handle_trim_video = async (videoBlob: Blob): Promise<void> => {
|
|
90
|
+
let _video_blob = new File([videoBlob], "video.mp4");
|
|
91
|
+
const val = await prepare_files([_video_blob]);
|
|
92
|
+
let value = ((await upload(val, root))?.filter(Boolean) as FileData[])[0];
|
|
93
|
+
|
|
94
|
+
handle_change(value);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
function open_full_screen(): void {
|
|
98
|
+
video.requestFullscreen();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
$: time = time || 0;
|
|
102
|
+
$: duration = duration || 0;
|
|
71
103
|
</script>
|
|
72
104
|
|
|
73
105
|
<div class="wrap">
|
|
@@ -156,7 +188,7 @@ $: duration = duration || 0;
|
|
|
156
188
|
/>
|
|
157
189
|
{/if}
|
|
158
190
|
|
|
159
|
-
<style>
|
|
191
|
+
<style lang="postcss">
|
|
160
192
|
span {
|
|
161
193
|
text-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
|
|
162
194
|
}
|
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { FileData, Client } from "@gradio/client";
|
|
3
2
|
import type { I18nFormatter } from "@gradio/utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
handle_change?: (video: FileData) => void;
|
|
15
|
-
handle_reset_value?: () => void;
|
|
16
|
-
upload: Client["upload"];
|
|
17
|
-
is_stream: boolean | undefined;
|
|
18
|
-
i18n: I18nFormatter;
|
|
19
|
-
show_download_button?: boolean;
|
|
20
|
-
value?: FileData | null;
|
|
21
|
-
handle_clear?: () => void;
|
|
22
|
-
has_change_history?: boolean;
|
|
3
|
+
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
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
23
13
|
};
|
|
24
|
-
|
|
25
|
-
play: CustomEvent<any>;
|
|
26
|
-
pause: CustomEvent<any>;
|
|
27
|
-
error: CustomEvent<any>;
|
|
28
|
-
loadstart: Event;
|
|
29
|
-
loadeddata: Event;
|
|
30
|
-
loadedmetadata: Event;
|
|
31
|
-
stop: CustomEvent<undefined>;
|
|
32
|
-
end: CustomEvent<undefined>;
|
|
33
|
-
clear: CustomEvent<undefined>;
|
|
34
|
-
} & {
|
|
35
|
-
[evt: string]: CustomEvent<any>;
|
|
36
|
-
};
|
|
37
|
-
slots: {};
|
|
38
|
-
exports?: {} | undefined;
|
|
39
|
-
bindings?: string | undefined;
|
|
40
|
-
};
|
|
41
|
-
export type PlayerProps = typeof __propDef.props;
|
|
42
|
-
export type PlayerEvents = typeof __propDef.events;
|
|
43
|
-
export type PlayerSlots = typeof __propDef.slots;
|
|
44
|
-
export default class Player extends SvelteComponent<PlayerProps, PlayerEvents, PlayerSlots> {
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
45
15
|
}
|
|
46
|
-
|
|
16
|
+
declare const Player: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
root?: string;
|
|
18
|
+
src: string;
|
|
19
|
+
subtitle?: string | null;
|
|
20
|
+
mirror: boolean;
|
|
21
|
+
autoplay: boolean;
|
|
22
|
+
loop: boolean;
|
|
23
|
+
label?: string;
|
|
24
|
+
interactive?: boolean;
|
|
25
|
+
handle_change?: (video: FileData) => void;
|
|
26
|
+
handle_reset_value?: () => void;
|
|
27
|
+
upload: Client["upload"];
|
|
28
|
+
is_stream: boolean | undefined;
|
|
29
|
+
i18n: I18nFormatter;
|
|
30
|
+
show_download_button?: boolean;
|
|
31
|
+
value?: FileData | null;
|
|
32
|
+
handle_clear?: () => void;
|
|
33
|
+
has_change_history?: boolean;
|
|
34
|
+
}, {
|
|
35
|
+
play: CustomEvent<any>;
|
|
36
|
+
pause: CustomEvent<any>;
|
|
37
|
+
error: CustomEvent<any>;
|
|
38
|
+
loadstart: Event;
|
|
39
|
+
loadeddata: Event;
|
|
40
|
+
loadedmetadata: Event;
|
|
41
|
+
stop: CustomEvent<undefined>;
|
|
42
|
+
end: CustomEvent<undefined>;
|
|
43
|
+
clear: CustomEvent<undefined>;
|
|
44
|
+
} & {
|
|
45
|
+
[evt: string]: CustomEvent<any>;
|
|
46
|
+
}, {}, {}, string>;
|
|
47
|
+
type Player = InstanceType<typeof Player>;
|
|
48
|
+
export default Player;
|
package/dist/shared/Video.svelte
CHANGED
|
@@ -1,65 +1,80 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export let
|
|
9
|
-
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
export let
|
|
14
|
-
export let
|
|
15
|
-
|
|
16
|
-
export let
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLVideoAttributes } from "svelte/elements";
|
|
3
|
+
import { createEventDispatcher } from "svelte";
|
|
4
|
+
import { loaded } from "./utils";
|
|
5
|
+
|
|
6
|
+
import Hls from "hls.js";
|
|
7
|
+
|
|
8
|
+
export let src: HTMLVideoAttributes["src"] = undefined;
|
|
9
|
+
|
|
10
|
+
export let muted: HTMLVideoAttributes["muted"] = undefined;
|
|
11
|
+
export let playsinline: HTMLVideoAttributes["playsinline"] = undefined;
|
|
12
|
+
export let preload: HTMLVideoAttributes["preload"] = undefined;
|
|
13
|
+
export let autoplay: HTMLVideoAttributes["autoplay"] = undefined;
|
|
14
|
+
export let controls: HTMLVideoAttributes["controls"] = undefined;
|
|
15
|
+
|
|
16
|
+
export let currentTime: number | undefined = undefined;
|
|
17
|
+
export let duration: number | undefined = undefined;
|
|
18
|
+
export let paused: boolean | undefined = undefined;
|
|
19
|
+
|
|
20
|
+
export let node: HTMLVideoElement | undefined = undefined;
|
|
21
|
+
export let loop: boolean;
|
|
22
|
+
export let is_stream;
|
|
23
|
+
|
|
24
|
+
export let processingVideo = false;
|
|
25
|
+
|
|
26
|
+
let stream_active = false;
|
|
27
|
+
|
|
28
|
+
const dispatch = createEventDispatcher();
|
|
29
|
+
|
|
30
|
+
function load_stream(
|
|
31
|
+
src: string | null | undefined,
|
|
32
|
+
is_stream: boolean,
|
|
33
|
+
node: HTMLVideoElement
|
|
34
|
+
): void {
|
|
35
|
+
if (!src || !is_stream) return;
|
|
36
|
+
|
|
37
|
+
if (Hls.isSupported() && !stream_active) {
|
|
38
|
+
const hls = new Hls({
|
|
39
|
+
maxBufferLength: 1, // 0.5 seconds (500 ms)
|
|
40
|
+
maxMaxBufferLength: 1, // Maximum max buffer length in seconds
|
|
41
|
+
lowLatencyMode: true // Enable low latency mode
|
|
42
|
+
});
|
|
43
|
+
hls.loadSource(src);
|
|
44
|
+
hls.attachMedia(node);
|
|
45
|
+
hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
|
46
|
+
(node as HTMLVideoElement).play();
|
|
47
|
+
});
|
|
48
|
+
hls.on(Hls.Events.ERROR, function (event, data) {
|
|
49
|
+
console.error("HLS error:", event, data);
|
|
50
|
+
if (data.fatal) {
|
|
51
|
+
switch (data.type) {
|
|
52
|
+
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
53
|
+
console.error(
|
|
54
|
+
"Fatal network error encountered, trying to recover"
|
|
55
|
+
);
|
|
56
|
+
hls.startLoad();
|
|
57
|
+
break;
|
|
58
|
+
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
59
|
+
console.error("Fatal media error encountered, trying to recover");
|
|
60
|
+
hls.recoverMediaError();
|
|
61
|
+
break;
|
|
62
|
+
default:
|
|
63
|
+
console.error("Fatal error, cannot recover");
|
|
64
|
+
hls.destroy();
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
stream_active = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
$: (src, (stream_active = false));
|
|
74
|
+
|
|
75
|
+
$: if (node && src && is_stream) {
|
|
76
|
+
load_stream(src, is_stream, node);
|
|
77
|
+
}
|
|
63
78
|
</script>
|
|
64
79
|
|
|
65
80
|
<!--
|
|
@@ -1,38 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
controls?: HTMLVideoAttributes["controls"];
|
|
12
|
-
currentTime?: number | undefined;
|
|
13
|
-
duration?: number | undefined;
|
|
14
|
-
paused?: boolean | undefined;
|
|
15
|
-
node?: HTMLVideoElement | undefined;
|
|
16
|
-
loop: boolean;
|
|
17
|
-
is_stream: any;
|
|
18
|
-
processingVideo?: boolean | undefined;
|
|
1
|
+
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> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
19
11
|
};
|
|
20
|
-
|
|
21
|
-
loadstart: Event;
|
|
22
|
-
loadeddata: Event;
|
|
23
|
-
loadedmetadata: Event;
|
|
24
|
-
} & {
|
|
25
|
-
[evt: string]: CustomEvent<any>;
|
|
26
|
-
};
|
|
27
|
-
slots: {
|
|
28
|
-
default: {};
|
|
29
|
-
};
|
|
30
|
-
exports?: undefined;
|
|
31
|
-
bindings?: undefined;
|
|
32
|
-
};
|
|
33
|
-
export type VideoProps = typeof __propDef.props;
|
|
34
|
-
export type VideoEvents = typeof __propDef.events;
|
|
35
|
-
export type VideoSlots = typeof __propDef.slots;
|
|
36
|
-
export default class Video extends SvelteComponent<VideoProps, VideoEvents, VideoSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
37
13
|
}
|
|
38
|
-
|
|
14
|
+
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
15
|
+
default: any;
|
|
16
|
+
} ? Props extends Record<string, never> ? any : {
|
|
17
|
+
children?: any;
|
|
18
|
+
} : {});
|
|
19
|
+
declare const Video: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
|
|
20
|
+
[x: string]: any;
|
|
21
|
+
src?: string | null | undefined;
|
|
22
|
+
muted?: boolean | null | undefined;
|
|
23
|
+
playsinline?: boolean | null | undefined;
|
|
24
|
+
preload?: "" | "auto" | "none" | "metadata" | null | undefined;
|
|
25
|
+
autoplay?: boolean | null | undefined;
|
|
26
|
+
controls?: boolean | null | undefined;
|
|
27
|
+
currentTime?: number | undefined | undefined;
|
|
28
|
+
duration?: number | undefined | undefined;
|
|
29
|
+
paused?: boolean | undefined | undefined;
|
|
30
|
+
node?: HTMLVideoElement | undefined;
|
|
31
|
+
loop: boolean;
|
|
32
|
+
is_stream: any;
|
|
33
|
+
processingVideo?: boolean | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
default: {};
|
|
36
|
+
}>, {
|
|
37
|
+
loadstart: Event;
|
|
38
|
+
loadeddata: Event;
|
|
39
|
+
loadedmetadata: Event;
|
|
40
|
+
} & {
|
|
41
|
+
[evt: string]: CustomEvent<any>;
|
|
42
|
+
}, {
|
|
43
|
+
default: {};
|
|
44
|
+
}, {}, string>;
|
|
45
|
+
type Video = InstanceType<typeof Video>;
|
|
46
|
+
export default Video;
|