@videts/vide 0.8.0 → 0.9.3
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/README.md +11 -11
- package/dist/chunk-2OVLZ27V.mjs +1 -0
- package/dist/chunk-3RDTWUHH.mjs +1 -0
- package/dist/chunk-6DWWYSH4.mjs +1 -0
- package/dist/chunk-G74QBLVV.mjs +1 -0
- package/dist/chunk-JRU2FKRB.mjs +2 -0
- package/dist/chunk-LPSJOF2I.mjs +2 -0
- package/dist/chunk-NA4C7W64.mjs +2 -0
- package/dist/chunk-UY5CGRNN.mjs +1 -0
- package/dist/chunk-VPH4JIJV.mjs +1 -0
- package/dist/chunk-WINCDUN5.mjs +1 -0
- package/dist/dash/index.d.ts +3 -9
- package/dist/dash/index.js +1 -0
- package/dist/dash/index.mjs +1 -2
- package/dist/drm/index.d.ts +4 -31
- package/dist/drm/index.js +1 -0
- package/dist/drm/index.mjs +1 -1
- package/dist/hls/index.d.ts +3 -9
- package/dist/hls/index.js +1 -0
- package/dist/hls/index.mjs +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -1
- package/dist/omid/index.d.ts +2 -2
- package/dist/omid/index.js +2 -0
- package/dist/react/index.d.ts +240 -0
- package/dist/react/index.js +2 -0
- package/dist/react/index.mjs +2 -0
- package/dist/simid/index.d.ts +2 -2
- package/dist/simid/index.js +1 -0
- package/dist/ssai/index.d.ts +4 -40
- package/dist/ssai/index.js +1 -0
- package/dist/ssai/index.mjs +1 -1
- package/dist/svelte/DashPlugin.svelte +23 -0
- package/dist/svelte/DashPlugin.svelte.d.ts +4 -0
- package/dist/svelte/DrmPlugin.svelte +20 -0
- package/dist/svelte/DrmPlugin.svelte.d.ts +4 -0
- package/dist/svelte/HlsPlugin.svelte +23 -0
- package/dist/svelte/HlsPlugin.svelte.d.ts +4 -0
- package/dist/svelte/SsaiPlugin.svelte +23 -0
- package/dist/svelte/SsaiPlugin.svelte.d.ts +4 -0
- package/dist/svelte/VastPlugin.svelte +20 -0
- package/dist/svelte/VastPlugin.svelte.d.ts +4 -0
- package/dist/svelte/VideControls.svelte +22 -0
- package/dist/svelte/VideControls.svelte.d.ts +8 -0
- package/dist/svelte/VideUI.svelte +49 -0
- package/dist/svelte/VideUI.svelte.d.ts +9 -0
- package/dist/svelte/Video.svelte +31 -0
- package/dist/svelte/Video.svelte.d.ts +10 -0
- package/dist/svelte/VmapPlugin.svelte +20 -0
- package/dist/svelte/VmapPlugin.svelte.d.ts +4 -0
- package/dist/svelte/components/AdCountdown.svelte +37 -0
- package/dist/svelte/components/AdCountdown.svelte.d.ts +7 -0
- package/dist/svelte/components/AdLabel.svelte +26 -0
- package/dist/svelte/components/AdLabel.svelte.d.ts +8 -0
- package/dist/svelte/components/AdLearnMore.svelte +42 -0
- package/dist/svelte/components/AdLearnMore.svelte.d.ts +9 -0
- package/dist/svelte/components/AdOverlay.svelte +46 -0
- package/dist/svelte/components/AdOverlay.svelte.d.ts +8 -0
- package/dist/svelte/components/AdSkip.svelte +67 -0
- package/dist/svelte/components/AdSkip.svelte.d.ts +8 -0
- package/dist/svelte/components/BigPlayButton.svelte +46 -0
- package/dist/svelte/components/BigPlayButton.svelte.d.ts +8 -0
- package/dist/svelte/components/ClickPlay.svelte +76 -0
- package/dist/svelte/components/ClickPlay.svelte.d.ts +7 -0
- package/dist/svelte/components/ErrorDisplay.svelte +27 -0
- package/dist/svelte/components/ErrorDisplay.svelte.d.ts +6 -0
- package/dist/svelte/components/FullscreenButton.svelte +65 -0
- package/dist/svelte/components/FullscreenButton.svelte.d.ts +9 -0
- package/dist/svelte/components/Loader.svelte +11 -0
- package/dist/svelte/components/Loader.svelte.d.ts +6 -0
- package/dist/svelte/components/MuteButton.svelte +57 -0
- package/dist/svelte/components/MuteButton.svelte.d.ts +8 -0
- package/dist/svelte/components/PlayButton.svelte +63 -0
- package/dist/svelte/components/PlayButton.svelte.d.ts +8 -0
- package/dist/svelte/components/Poster.svelte +13 -0
- package/dist/svelte/components/Poster.svelte.d.ts +8 -0
- package/dist/svelte/components/Progress.svelte +101 -0
- package/dist/svelte/components/Progress.svelte.d.ts +6 -0
- package/dist/svelte/components/TimeDisplay.svelte +33 -0
- package/dist/svelte/components/TimeDisplay.svelte.d.ts +7 -0
- package/dist/svelte/components/Volume.svelte +117 -0
- package/dist/svelte/components/Volume.svelte.d.ts +8 -0
- package/dist/svelte/context.d.ts +6 -0
- package/dist/svelte/context.js +10 -0
- package/dist/svelte/create-vide-player.svelte.d.ts +2 -0
- package/dist/svelte/create-vide-player.svelte.js +22 -0
- package/dist/svelte/helpers.d.ts +17 -0
- package/dist/svelte/helpers.js +31 -0
- package/dist/svelte/icons/IconFullscreenEnter.svelte +3 -0
- package/dist/svelte/icons/IconFullscreenEnter.svelte.d.ts +26 -0
- package/dist/svelte/icons/IconFullscreenExit.svelte +3 -0
- package/dist/svelte/icons/IconFullscreenExit.svelte.d.ts +26 -0
- package/dist/svelte/icons/IconPause.svelte +3 -0
- package/dist/svelte/icons/IconPause.svelte.d.ts +26 -0
- package/dist/svelte/icons/IconPlay.svelte +3 -0
- package/dist/svelte/icons/IconPlay.svelte.d.ts +26 -0
- package/dist/svelte/icons/IconVolumeHigh.svelte +3 -0
- package/dist/svelte/icons/IconVolumeHigh.svelte.d.ts +26 -0
- package/dist/svelte/icons/IconVolumeLow.svelte +3 -0
- package/dist/svelte/icons/IconVolumeLow.svelte.d.ts +26 -0
- package/dist/svelte/icons/IconVolumeMute.svelte +3 -0
- package/dist/svelte/icons/IconVolumeMute.svelte.d.ts +26 -0
- package/dist/svelte/index.d.ts +42 -0
- package/dist/svelte/index.js +39 -0
- package/dist/svelte/use-ad-state.svelte.d.ts +7 -0
- package/dist/svelte/use-ad-state.svelte.js +40 -0
- package/dist/svelte/use-autohide.svelte.d.ts +2 -0
- package/dist/svelte/use-autohide.svelte.js +68 -0
- package/dist/svelte/use-keyboard.svelte.d.ts +7 -0
- package/dist/svelte/use-keyboard.svelte.js +96 -0
- package/dist/svelte/use-plugin.svelte.d.ts +15 -0
- package/dist/svelte/use-plugin.svelte.js +40 -0
- package/dist/svelte/use-vide-event.svelte.d.ts +3 -0
- package/dist/svelte/use-vide-event.svelte.js +9 -0
- package/dist/{types-vxIcXgJz.d.ts → types-BsEF8iWC.d.ts} +106 -1
- package/dist/types-C1_eVsFF.d.ts +49 -0
- package/dist/types-C6XFF6w_.d.ts +30 -0
- package/dist/types-COeag8fU.d.ts +173 -0
- package/dist/types-CwjR99DL.d.ts +10 -0
- package/dist/types-DsixuzNX.d.ts +52 -0
- package/dist/types-DzY1cmXC.d.ts +10 -0
- package/dist/types-SuT99_Z3.d.ts +40 -0
- package/dist/ui/index.d.ts +7 -37
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.mjs +1 -2
- package/dist/ui/theme.css +138 -46
- package/dist/vast/index.d.ts +188 -4
- package/dist/vast/index.js +1 -0
- package/dist/vast/index.mjs +1 -1
- package/dist/vide.core.global.js +1 -1
- package/dist/vide.global.js +2 -2
- package/dist/vide.ssai.global.js +1 -1
- package/dist/vide.ui.css +138 -46
- package/dist/vide.ui.global.js +1 -1
- package/dist/vide.vast.global.js +1 -1
- package/dist/vide.vmap.global.js +1 -1
- package/dist/vmap/index.d.ts +5 -49
- package/dist/vmap/index.js +1 -0
- package/dist/vmap/index.mjs +1 -1
- package/dist/vue/index.d.ts +354 -0
- package/dist/vue/index.js +2 -0
- package/dist/vue/index.mjs +2 -0
- package/package.json +47 -6
- package/dist/chunk-726XNUGZ.mjs +0 -1
- package/dist/chunk-G4Q7R3SH.mjs +0 -1
- package/dist/types-CAJmacV6.d.ts +0 -98
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import { type PlayerGetter, VIDE_PLAYER_KEY } from "../context.js";
|
|
5
|
+
import IconVolumeHigh from "../icons/IconVolumeHigh.svelte";
|
|
6
|
+
import IconVolumeLow from "../icons/IconVolumeLow.svelte";
|
|
7
|
+
import IconVolumeMute from "../icons/IconVolumeMute.svelte";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
class?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { class: className, children }: Props = $props();
|
|
15
|
+
|
|
16
|
+
const getPlayer = getContext<PlayerGetter>(VIDE_PLAYER_KEY);
|
|
17
|
+
let muted = $state(false);
|
|
18
|
+
let volume = $state(1);
|
|
19
|
+
|
|
20
|
+
$effect(() => {
|
|
21
|
+
const p = getPlayer();
|
|
22
|
+
if (!p) return;
|
|
23
|
+
const sync = () => {
|
|
24
|
+
muted = p.muted || p.volume === 0;
|
|
25
|
+
volume = p.volume;
|
|
26
|
+
};
|
|
27
|
+
p.el.addEventListener("volumechange", sync);
|
|
28
|
+
sync();
|
|
29
|
+
return () => {
|
|
30
|
+
p.el.removeEventListener("volumechange", sync);
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
function onClick() {
|
|
35
|
+
const p = getPlayer();
|
|
36
|
+
if (!p) return;
|
|
37
|
+
p.muted = !p.muted;
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
class={["vide-mute", className].filter(Boolean).join(" ")}
|
|
44
|
+
aria-label={muted ? "Unmute" : "Mute"}
|
|
45
|
+
data-muted={muted || undefined}
|
|
46
|
+
onclick={onClick}
|
|
47
|
+
>
|
|
48
|
+
{#if children}
|
|
49
|
+
{@render children()}
|
|
50
|
+
{:else if muted}
|
|
51
|
+
<IconVolumeMute />
|
|
52
|
+
{:else if volume < 0.5}
|
|
53
|
+
<IconVolumeLow />
|
|
54
|
+
{:else}
|
|
55
|
+
<IconVolumeHigh />
|
|
56
|
+
{/if}
|
|
57
|
+
</button>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import { type PlayerGetter, VIDE_PLAYER_KEY } from "../context.js";
|
|
5
|
+
import type { PlayerState } from "../helpers.js";
|
|
6
|
+
import IconPause from "../icons/IconPause.svelte";
|
|
7
|
+
import IconPlay from "../icons/IconPlay.svelte";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
class?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { class: className, children }: Props = $props();
|
|
15
|
+
|
|
16
|
+
const getPlayer = getContext<PlayerGetter>(VIDE_PLAYER_KEY);
|
|
17
|
+
let playing = $state(false);
|
|
18
|
+
|
|
19
|
+
$effect(() => {
|
|
20
|
+
const p = getPlayer();
|
|
21
|
+
if (!p) return;
|
|
22
|
+
const handler = ({ to }: { from: PlayerState; to: PlayerState }) => {
|
|
23
|
+
if (to === "playing" || to === "ad:playing") {
|
|
24
|
+
playing = true;
|
|
25
|
+
} else if (
|
|
26
|
+
to === "paused" ||
|
|
27
|
+
to === "ready" ||
|
|
28
|
+
to === "ended" ||
|
|
29
|
+
to === "ad:paused"
|
|
30
|
+
) {
|
|
31
|
+
playing = false;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
p.on("statechange", handler);
|
|
35
|
+
return () => p.off("statechange", handler);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function onClick() {
|
|
39
|
+
const p = getPlayer();
|
|
40
|
+
if (!p) return;
|
|
41
|
+
if (p.state === "playing" || p.state === "ad:playing") {
|
|
42
|
+
p.pause();
|
|
43
|
+
} else {
|
|
44
|
+
p.play().catch(() => {});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<button
|
|
50
|
+
type="button"
|
|
51
|
+
class={["vide-play", className].filter(Boolean).join(" ")}
|
|
52
|
+
aria-label={playing ? "Pause" : "Play"}
|
|
53
|
+
data-playing={playing || undefined}
|
|
54
|
+
onclick={onClick}
|
|
55
|
+
>
|
|
56
|
+
{#if children}
|
|
57
|
+
{@render children()}
|
|
58
|
+
{:else if playing}
|
|
59
|
+
<IconPause />
|
|
60
|
+
{:else}
|
|
61
|
+
<IconPlay />
|
|
62
|
+
{/if}
|
|
63
|
+
</button>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
src: string;
|
|
4
|
+
alt?: string;
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const { src, alt = "", class: className }: Props = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class={["vide-poster", className].filter(Boolean).join(" ")}>
|
|
12
|
+
<img class="vide-poster__image" {src} {alt} />
|
|
13
|
+
</div>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import { type PlayerGetter, VIDE_PLAYER_KEY } from "../context.js";
|
|
4
|
+
import type { PlayerState } from "../helpers.js";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
class?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const { class: className }: Props = $props();
|
|
11
|
+
|
|
12
|
+
const getPlayer = getContext<PlayerGetter>(VIDE_PLAYER_KEY);
|
|
13
|
+
let progress = $state(0);
|
|
14
|
+
let buffered = $state(0);
|
|
15
|
+
let disabled = $state(false);
|
|
16
|
+
let dragging = false;
|
|
17
|
+
let rootEl: HTMLDivElement;
|
|
18
|
+
|
|
19
|
+
$effect(() => {
|
|
20
|
+
const p = getPlayer();
|
|
21
|
+
if (!p) return;
|
|
22
|
+
const onTimeUpdate = ({
|
|
23
|
+
currentTime,
|
|
24
|
+
duration,
|
|
25
|
+
}: { currentTime: number; duration: number }) => {
|
|
26
|
+
if (!dragging && duration > 0) {
|
|
27
|
+
progress = currentTime / duration;
|
|
28
|
+
}
|
|
29
|
+
if (p.el.buffered.length > 0 && duration > 0) {
|
|
30
|
+
const end = p.el.buffered.end(p.el.buffered.length - 1);
|
|
31
|
+
buffered = Math.min(1, end / duration);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
p.on("timeupdate", onTimeUpdate);
|
|
35
|
+
return () => p.off("timeupdate", onTimeUpdate);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
$effect(() => {
|
|
39
|
+
const p = getPlayer();
|
|
40
|
+
if (!p) return;
|
|
41
|
+
const onStateChange = ({ to }: { from: PlayerState; to: PlayerState }) => {
|
|
42
|
+
const isAd =
|
|
43
|
+
to === "ad:loading" || to === "ad:playing" || to === "ad:paused";
|
|
44
|
+
disabled = isAd;
|
|
45
|
+
};
|
|
46
|
+
p.on("statechange", onStateChange);
|
|
47
|
+
return () => p.off("statechange", onStateChange);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
function getRatio(e: PointerEvent): number {
|
|
51
|
+
if (!rootEl) return 0;
|
|
52
|
+
const rect = rootEl.getBoundingClientRect();
|
|
53
|
+
if (rect.width === 0) return 0;
|
|
54
|
+
return Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function onPointerDown(e: PointerEvent) {
|
|
58
|
+
const p = getPlayer();
|
|
59
|
+
if (!p || disabled) return;
|
|
60
|
+
dragging = true;
|
|
61
|
+
rootEl?.setPointerCapture(e.pointerId);
|
|
62
|
+
progress = getRatio(e);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function onPointerMove(e: PointerEvent) {
|
|
66
|
+
if (!dragging) return;
|
|
67
|
+
progress = getRatio(e);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function onPointerUp(e: PointerEvent) {
|
|
71
|
+
const p = getPlayer();
|
|
72
|
+
if (!dragging || !p) return;
|
|
73
|
+
dragging = false;
|
|
74
|
+
rootEl?.releasePointerCapture(e.pointerId);
|
|
75
|
+
const ratio = getRatio(e);
|
|
76
|
+
const duration = p.el.duration;
|
|
77
|
+
if (Number.isFinite(duration) && duration > 0) {
|
|
78
|
+
p.currentTime = ratio * duration;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<div
|
|
84
|
+
bind:this={rootEl}
|
|
85
|
+
class={["vide-progress", className].filter(Boolean).join(" ")}
|
|
86
|
+
role="slider"
|
|
87
|
+
tabindex="0"
|
|
88
|
+
aria-label="Seek"
|
|
89
|
+
aria-valuemin="0"
|
|
90
|
+
aria-valuemax="100"
|
|
91
|
+
aria-valuenow={Math.round(progress * 100)}
|
|
92
|
+
data-disabled={disabled || undefined}
|
|
93
|
+
style="--vide-progress: {progress}; --vide-progress-buffered: {buffered}"
|
|
94
|
+
onpointerdown={onPointerDown}
|
|
95
|
+
onpointermove={onPointerMove}
|
|
96
|
+
onpointerup={onPointerUp}
|
|
97
|
+
>
|
|
98
|
+
<div class="vide-progress__buffered"></div>
|
|
99
|
+
<div class="vide-progress__bar"></div>
|
|
100
|
+
<div class="vide-progress__handle"></div>
|
|
101
|
+
</div>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import { type PlayerGetter, VIDE_PLAYER_KEY } from "../context.js";
|
|
4
|
+
import { formatTime } from "../helpers.js";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
class?: string;
|
|
8
|
+
separator?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { class: className, separator = "/" }: Props = $props();
|
|
12
|
+
|
|
13
|
+
const getPlayer = getContext<PlayerGetter>(VIDE_PLAYER_KEY);
|
|
14
|
+
let currentTime = $state(0);
|
|
15
|
+
let duration = $state(0);
|
|
16
|
+
|
|
17
|
+
$effect(() => {
|
|
18
|
+
const p = getPlayer();
|
|
19
|
+
if (!p) return;
|
|
20
|
+
const handler = (data: { currentTime: number; duration: number }) => {
|
|
21
|
+
currentTime = data.currentTime;
|
|
22
|
+
duration = data.duration;
|
|
23
|
+
};
|
|
24
|
+
p.on("timeupdate", handler);
|
|
25
|
+
return () => p.off("timeupdate", handler);
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div class={["vide-time", className].filter(Boolean).join(" ")} aria-label="Time">
|
|
30
|
+
<span>{formatTime(currentTime)}</span>
|
|
31
|
+
<span>{separator}</span>
|
|
32
|
+
<span>{formatTime(duration)}</span>
|
|
33
|
+
</div>
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import type { Snippet } from "svelte";
|
|
4
|
+
import { type PlayerGetter, VIDE_PLAYER_KEY } from "../context.js";
|
|
5
|
+
import IconVolumeHigh from "../icons/IconVolumeHigh.svelte";
|
|
6
|
+
import IconVolumeLow from "../icons/IconVolumeLow.svelte";
|
|
7
|
+
import IconVolumeMute from "../icons/IconVolumeMute.svelte";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
class?: string;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { class: className, children }: Props = $props();
|
|
15
|
+
|
|
16
|
+
const getPlayer = getContext<PlayerGetter>(VIDE_PLAYER_KEY);
|
|
17
|
+
let volume = $state(1);
|
|
18
|
+
let muted = $state(false);
|
|
19
|
+
let dragging = false;
|
|
20
|
+
let sliderEl: HTMLDivElement;
|
|
21
|
+
|
|
22
|
+
$effect(() => {
|
|
23
|
+
const p = getPlayer();
|
|
24
|
+
if (!p) return;
|
|
25
|
+
const sync = () => {
|
|
26
|
+
if (!dragging) {
|
|
27
|
+
volume = p.muted ? 0 : p.volume;
|
|
28
|
+
}
|
|
29
|
+
muted = p.muted || p.volume === 0;
|
|
30
|
+
};
|
|
31
|
+
p.el.addEventListener("volumechange", sync);
|
|
32
|
+
sync();
|
|
33
|
+
return () => {
|
|
34
|
+
p.el.removeEventListener("volumechange", sync);
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function onMuteClick() {
|
|
39
|
+
const p = getPlayer();
|
|
40
|
+
if (!p) return;
|
|
41
|
+
p.muted = !p.muted;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getRatio(e: PointerEvent): number {
|
|
45
|
+
if (!sliderEl) return 0;
|
|
46
|
+
const rect = sliderEl.getBoundingClientRect();
|
|
47
|
+
if (rect.width === 0) return 0;
|
|
48
|
+
return Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function onPointerDown(e: PointerEvent) {
|
|
52
|
+
const p = getPlayer();
|
|
53
|
+
if (!p) return;
|
|
54
|
+
dragging = true;
|
|
55
|
+
sliderEl?.setPointerCapture(e.pointerId);
|
|
56
|
+
const vol = getRatio(e);
|
|
57
|
+
p.volume = vol;
|
|
58
|
+
if (p.muted && vol > 0) p.muted = false;
|
|
59
|
+
volume = vol;
|
|
60
|
+
muted = vol === 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function onPointerMove(e: PointerEvent) {
|
|
64
|
+
const p = getPlayer();
|
|
65
|
+
if (!dragging || !p) return;
|
|
66
|
+
const vol = getRatio(e);
|
|
67
|
+
p.volume = vol;
|
|
68
|
+
if (p.muted && vol > 0) p.muted = false;
|
|
69
|
+
volume = vol;
|
|
70
|
+
muted = vol === 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function onPointerUp(e: PointerEvent) {
|
|
74
|
+
if (!dragging) return;
|
|
75
|
+
dragging = false;
|
|
76
|
+
sliderEl?.releasePointerCapture(e.pointerId);
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<div
|
|
81
|
+
class={["vide-volume", className].filter(Boolean).join(" ")}
|
|
82
|
+
data-muted={muted || undefined}
|
|
83
|
+
style="--vide-volume: {volume}"
|
|
84
|
+
>
|
|
85
|
+
<button
|
|
86
|
+
type="button"
|
|
87
|
+
class="vide-volume__button"
|
|
88
|
+
aria-label={muted ? "Unmute" : "Mute"}
|
|
89
|
+
onclick={onMuteClick}
|
|
90
|
+
>
|
|
91
|
+
{#if children}
|
|
92
|
+
{@render children()}
|
|
93
|
+
{:else if muted}
|
|
94
|
+
<IconVolumeMute />
|
|
95
|
+
{:else if volume < 0.5}
|
|
96
|
+
<IconVolumeLow />
|
|
97
|
+
{:else}
|
|
98
|
+
<IconVolumeHigh />
|
|
99
|
+
{/if}
|
|
100
|
+
</button>
|
|
101
|
+
<div
|
|
102
|
+
bind:this={sliderEl}
|
|
103
|
+
class="vide-volume__slider"
|
|
104
|
+
role="slider"
|
|
105
|
+
tabindex="0"
|
|
106
|
+
aria-label="Volume"
|
|
107
|
+
aria-valuemin="0"
|
|
108
|
+
aria-valuemax="100"
|
|
109
|
+
aria-valuenow={Math.round(volume * 100)}
|
|
110
|
+
onpointerdown={onPointerDown}
|
|
111
|
+
onpointermove={onPointerMove}
|
|
112
|
+
onpointerup={onPointerUp}
|
|
113
|
+
>
|
|
114
|
+
<div class="vide-volume__track"></div>
|
|
115
|
+
<div class="vide-volume__filled"></div>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MediaElement, Player } from "./helpers.js";
|
|
2
|
+
export declare const VIDE_PLAYER_KEY: unique symbol;
|
|
3
|
+
export declare const VIDE_REGISTER_KEY: unique symbol;
|
|
4
|
+
export type PlayerGetter = () => Player | null;
|
|
5
|
+
export type RegisterFn = (el: MediaElement) => void;
|
|
6
|
+
export declare function useVideContext(): PlayerGetter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getContext } from "svelte";
|
|
2
|
+
export const VIDE_PLAYER_KEY = Symbol("vide-player");
|
|
3
|
+
export const VIDE_REGISTER_KEY = Symbol("vide-register");
|
|
4
|
+
export function useVideContext() {
|
|
5
|
+
const getter = getContext(VIDE_PLAYER_KEY);
|
|
6
|
+
if (!getter) {
|
|
7
|
+
throw new Error("useVideContext must be used within <VideVideo>");
|
|
8
|
+
}
|
|
9
|
+
return getter;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { setContext } from "svelte";
|
|
2
|
+
import { VIDE_PLAYER_KEY, VIDE_REGISTER_KEY, } from "./context.js";
|
|
3
|
+
import { createPlayer } from "./helpers.js";
|
|
4
|
+
export function createVidePlayer() {
|
|
5
|
+
let player = $state(null);
|
|
6
|
+
const registerEl = (el) => {
|
|
7
|
+
if (player) {
|
|
8
|
+
player.destroy();
|
|
9
|
+
}
|
|
10
|
+
player = createPlayer(el);
|
|
11
|
+
};
|
|
12
|
+
$effect(() => {
|
|
13
|
+
const p = player;
|
|
14
|
+
return () => {
|
|
15
|
+
p?.destroy();
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
const getPlayer = () => player;
|
|
19
|
+
setContext(VIDE_PLAYER_KEY, getPlayer);
|
|
20
|
+
setContext(VIDE_REGISTER_KEY, registerEl);
|
|
21
|
+
return getPlayer;
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlined utilities and re-exports for the Svelte integration.
|
|
3
|
+
*
|
|
4
|
+
* svelte-package copies .svelte and .svelte.ts files as-is, preserving their
|
|
5
|
+
* import specifiers. Cross-entry imports like "../ui/state.js" break at
|
|
6
|
+
* runtime because tsup bundles those source files into entry-point index files.
|
|
7
|
+
*
|
|
8
|
+
* This module re-exports what the Svelte layer needs from the bundled core
|
|
9
|
+
* entry ("../index.js") and inlines the tiny UI helpers so that no Svelte
|
|
10
|
+
* source file imports across entry-point boundaries.
|
|
11
|
+
*/
|
|
12
|
+
export { createPlayer } from "../index.js";
|
|
13
|
+
export type { AdMeta, EventHandler, MediaElement, Player, PlayerEvent, PlayerEventMap, PlayerState, Plugin, } from "../index.js";
|
|
14
|
+
import type { PlayerState } from "../index.js";
|
|
15
|
+
export declare function stateToClass(state: PlayerState): string;
|
|
16
|
+
export declare function isAdState(state: PlayerState): boolean;
|
|
17
|
+
export declare function formatTime(seconds: number): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inlined utilities and re-exports for the Svelte integration.
|
|
3
|
+
*
|
|
4
|
+
* svelte-package copies .svelte and .svelte.ts files as-is, preserving their
|
|
5
|
+
* import specifiers. Cross-entry imports like "../ui/state.js" break at
|
|
6
|
+
* runtime because tsup bundles those source files into entry-point index files.
|
|
7
|
+
*
|
|
8
|
+
* This module re-exports what the Svelte layer needs from the bundled core
|
|
9
|
+
* entry ("../index.js") and inlines the tiny UI helpers so that no Svelte
|
|
10
|
+
* source file imports across entry-point boundaries.
|
|
11
|
+
*/
|
|
12
|
+
// ── Re-exports from the bundled core entry point ─────────────────────
|
|
13
|
+
export { createPlayer } from "../index.js";
|
|
14
|
+
export function stateToClass(state) {
|
|
15
|
+
return `vide-ui--${state.replace(":", "-")}`;
|
|
16
|
+
}
|
|
17
|
+
export function isAdState(state) {
|
|
18
|
+
return (state === "ad:loading" || state === "ad:playing" || state === "ad:paused");
|
|
19
|
+
}
|
|
20
|
+
// ── Inlined from src/ui/utils.ts ─────────────────────────────────────
|
|
21
|
+
export function formatTime(seconds) {
|
|
22
|
+
if (!Number.isFinite(seconds) || seconds < 0)
|
|
23
|
+
return "0:00";
|
|
24
|
+
const s = Math.floor(seconds);
|
|
25
|
+
const h = Math.floor(s / 3600);
|
|
26
|
+
const m = Math.floor((s % 3600) / 60);
|
|
27
|
+
const sec = s % 60;
|
|
28
|
+
const mm = h > 0 ? String(m).padStart(2, "0") : String(m);
|
|
29
|
+
const ss = String(sec).padStart(2, "0");
|
|
30
|
+
return h > 0 ? `${h}:${mm}:${ss}` : `${mm}:${ss}`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default IconFullscreenEnter;
|
|
2
|
+
type IconFullscreenEnter = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const IconFullscreenEnter: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
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> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default IconFullscreenExit;
|
|
2
|
+
type IconFullscreenExit = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const IconFullscreenExit: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
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> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default IconPause;
|
|
2
|
+
type IconPause = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const IconPause: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
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> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default IconPlay;
|
|
2
|
+
type IconPlay = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const IconPlay: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
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> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="currentColor" aria-hidden="true">
|
|
2
|
+
<path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z" />
|
|
3
|
+
</svg>
|