@maas/vue-equipment 1.0.0-beta.12 → 1.0.0-beta.14
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/dist/nuxt/module.json +1 -1
- package/dist/plugins/.turbo/turbo-lint.log +2 -2
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +65 -82
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +2 -2
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +24 -30
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +65 -61
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +41 -45
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue +137 -150
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +45 -52
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +80 -82
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue +40 -47
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +68 -74
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +22 -38
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +95 -85
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +41 -47
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue +41 -39
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue.d.ts +2 -2
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue +23 -34
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue +40 -73
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +70 -87
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +7 -7
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +262 -304
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +12 -12
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +100 -100
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +41 -69
- package/dist/plugins/MagicMarquee/src/composables/useMagicMarquee.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue +54 -59
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +188 -208
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue.d.ts +3 -3
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +181 -194
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +91 -100
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +83 -85
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +79 -75
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +106 -105
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +54 -60
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +1 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +136 -164
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +1 -1
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +53 -78
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +147 -175
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +51 -62
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +101 -122
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue.d.ts +8 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +35 -42
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +101 -108
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +49 -77
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue.d.ts +3 -3
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue +18 -37
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue.d.ts +1 -2
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +45 -52
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue.d.ts +5 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +60 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +74 -70
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +171 -213
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue.d.ts +8 -6
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerAudioApi.d.ts +0 -4
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerAudioApi.mjs +6 -47
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.d.ts +4 -31
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.mjs +147 -234
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.d.ts +1 -15
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +17 -164
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +6 -24
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.d.ts +7 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +56 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerVideoApi.d.ts +0 -5
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerVideoApi.mjs +7 -62
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +32 -51
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.mjs +47 -0
- package/dist/plugins/MagicPlayer/src/symbols/index.d.ts +5 -2
- package/dist/plugins/MagicPlayer/src/symbols/index.mjs +10 -1
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +29 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +49 -59
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +63 -70
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +29 -33
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +59 -69
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +80 -95
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +52 -70
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue.d.ts +2 -2
- package/package.json +4 -4
- package/dist/plugins/MagicAccordion/demo/data/footer.json +0 -117
- package/dist/plugins/MagicCommand/demo/data/about.json +0 -3
- package/dist/plugins/MagicCommand/demo/data/search.json +0 -594
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerStateEmitter.d.ts +0 -15
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerStateEmitter.mjs +0 -9
|
@@ -1,128 +1,107 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="magic-player-audio-controls"
|
|
4
|
+
:data-touched="touched"
|
|
5
|
+
:data-playing="playing"
|
|
6
|
+
:data-paused="!playing"
|
|
7
|
+
:data-waiting="waiting"
|
|
8
|
+
:data-idle="idle"
|
|
9
|
+
:data-hover="controlsMouseEntered"
|
|
10
|
+
@mouseenter="onMouseenter"
|
|
11
|
+
@mouseleave="onMouseleave"
|
|
12
|
+
>
|
|
13
|
+
<div class="magic-player-audio-controls__bar">
|
|
14
|
+
<div ref="bar" class="magic-player-audio-controls__bar--inner">
|
|
15
|
+
<div
|
|
16
|
+
class="magic-player-audio-controls__item -shrink-0"
|
|
17
|
+
data-slot="play-toggle"
|
|
18
|
+
>
|
|
19
|
+
<button v-if="!playing" @click="play">
|
|
20
|
+
<slot name="playIcon">
|
|
21
|
+
<icon-play />
|
|
22
|
+
</slot>
|
|
23
|
+
</button>
|
|
24
|
+
<button v-else @click="pause">
|
|
25
|
+
<slot name="pauseIcon">
|
|
26
|
+
<icon-pause />
|
|
27
|
+
</slot>
|
|
28
|
+
</button>
|
|
29
|
+
</div>
|
|
30
|
+
<div
|
|
31
|
+
class="magic-player-audio-controls__item -shrink-0"
|
|
32
|
+
data-slot="display-time-current"
|
|
33
|
+
>
|
|
34
|
+
<magic-player-display-time type="current" />
|
|
35
|
+
</div>
|
|
36
|
+
<div
|
|
37
|
+
class="magic-player-audio-controls__item -grow"
|
|
38
|
+
data-slot="timeline"
|
|
39
|
+
>
|
|
40
|
+
<div ref="track" class="magic-player-audio-controls__timeline">
|
|
41
|
+
<magic-player-timeline />
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<div
|
|
45
|
+
class="magic-player-audio-controls__item -shrink-0"
|
|
46
|
+
data-slot="display-time-duration"
|
|
47
|
+
>
|
|
48
|
+
<magic-player-display-time type="duration" />
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script setup>
|
|
56
|
+
import {
|
|
57
|
+
toRefs,
|
|
58
|
+
computed,
|
|
59
|
+
inject,
|
|
60
|
+
provide,
|
|
61
|
+
useTemplateRef,
|
|
62
|
+
onBeforeUnmount
|
|
63
|
+
} from "vue";
|
|
31
64
|
import { useIdle } from "@vueuse/core";
|
|
32
|
-
import {
|
|
65
|
+
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
33
66
|
import { usePlayerAudioApi } from "../composables/private/usePlayerAudioApi";
|
|
34
67
|
import { usePlayerControlsApi } from "../composables/private/usePlayerControlsApi";
|
|
35
|
-
import
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const injectedInstanceId = inject(MagicPlayerInstanceId, void 0);
|
|
45
|
-
const mappedInstanceId = computed(() => __props.instanceId ?? injectedInstanceId);
|
|
46
|
-
if (!mappedInstanceId.value) {
|
|
47
|
-
throw new Error(
|
|
48
|
-
"MagicAudioPlayerControls must be nested inside MagicAudioPlayer or an instanceId must be provided."
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
const barRef = useTemplateRef("bar");
|
|
52
|
-
const trackRef = useTemplateRef("track");
|
|
53
|
-
const { playing, waiting } = usePlayerMediaApi({
|
|
54
|
-
id: mappedInstanceId.value
|
|
55
|
-
});
|
|
56
|
-
const { play, pause, touched, mouseEntered } = usePlayerAudioApi({
|
|
57
|
-
id: mappedInstanceId.value
|
|
58
|
-
});
|
|
59
|
-
usePlayerControlsApi({
|
|
60
|
-
id: mappedInstanceId.value,
|
|
61
|
-
barRef,
|
|
62
|
-
trackRef
|
|
63
|
-
});
|
|
64
|
-
const { idle } = useIdle(3e3);
|
|
65
|
-
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
66
|
-
return (_ctx, _cache) => {
|
|
67
|
-
const _component_magic_player_display_time = _resolveComponent("magic-player-display-time");
|
|
68
|
-
const _component_magic_player_timeline = _resolveComponent("magic-player-timeline");
|
|
69
|
-
return _openBlock(), _createElementBlock("div", {
|
|
70
|
-
class: "magic-player-audio-controls",
|
|
71
|
-
"data-touched": _unref(touched),
|
|
72
|
-
"data-playing": _unref(playing),
|
|
73
|
-
"data-paused": !_unref(playing),
|
|
74
|
-
"data-waiting": _unref(waiting),
|
|
75
|
-
"data-idle": _unref(idle),
|
|
76
|
-
"data-hover": _unref(mouseEntered)
|
|
77
|
-
}, [
|
|
78
|
-
_createElementVNode("div", _hoisted_2, [
|
|
79
|
-
_createElementVNode(
|
|
80
|
-
"div",
|
|
81
|
-
_hoisted_3,
|
|
82
|
-
[
|
|
83
|
-
_createElementVNode("div", _hoisted_4, [
|
|
84
|
-
!_unref(playing) ? (_openBlock(), _createElementBlock("button", {
|
|
85
|
-
key: 0,
|
|
86
|
-
onClick: _cache[0] || (_cache[0] = //@ts-ignore
|
|
87
|
-
(...args) => _unref(play) && _unref(play)(...args))
|
|
88
|
-
}, [
|
|
89
|
-
_renderSlot(_ctx.$slots, "playIcon", {}, () => [
|
|
90
|
-
_createVNode(IconPlay)
|
|
91
|
-
])
|
|
92
|
-
])) : (_openBlock(), _createElementBlock("button", {
|
|
93
|
-
key: 1,
|
|
94
|
-
onClick: _cache[1] || (_cache[1] = //@ts-ignore
|
|
95
|
-
(...args) => _unref(pause) && _unref(pause)(...args))
|
|
96
|
-
}, [
|
|
97
|
-
_renderSlot(_ctx.$slots, "pauseIcon", {}, () => [
|
|
98
|
-
_createVNode(IconPause)
|
|
99
|
-
])
|
|
100
|
-
]))
|
|
101
|
-
]),
|
|
102
|
-
_createElementVNode("div", _hoisted_5, [
|
|
103
|
-
_createVNode(_component_magic_player_display_time, { type: "current" })
|
|
104
|
-
]),
|
|
105
|
-
_createElementVNode("div", _hoisted_6, [
|
|
106
|
-
_createElementVNode(
|
|
107
|
-
"div",
|
|
108
|
-
_hoisted_7,
|
|
109
|
-
[
|
|
110
|
-
_createVNode(_component_magic_player_timeline)
|
|
111
|
-
],
|
|
112
|
-
512
|
|
113
|
-
/* NEED_PATCH */
|
|
114
|
-
)
|
|
115
|
-
]),
|
|
116
|
-
_createElementVNode("div", _hoisted_8, [
|
|
117
|
-
_createVNode(_component_magic_player_display_time, { type: "duration" })
|
|
118
|
-
])
|
|
119
|
-
],
|
|
120
|
-
512
|
|
121
|
-
/* NEED_PATCH */
|
|
122
|
-
)
|
|
123
|
-
])
|
|
124
|
-
], 8, _hoisted_1);
|
|
125
|
-
};
|
|
68
|
+
import {
|
|
69
|
+
MagicPlayerInstanceId,
|
|
70
|
+
MagicPlayerTrackRef,
|
|
71
|
+
MagicPlayerBarRef
|
|
72
|
+
} from "../symbols";
|
|
73
|
+
const { instanceId } = defineProps({
|
|
74
|
+
instanceId: {
|
|
75
|
+
type: String,
|
|
76
|
+
required: false
|
|
126
77
|
}
|
|
127
78
|
});
|
|
79
|
+
const injectedInstanceId = inject(MagicPlayerInstanceId, void 0);
|
|
80
|
+
const mappedInstanceId = computed(() => instanceId ?? injectedInstanceId);
|
|
81
|
+
if (!mappedInstanceId.value) {
|
|
82
|
+
throw new Error(
|
|
83
|
+
"MagicAudioPlayerControls must be nested inside MagicAudioPlayer or an instanceId must be provided."
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const barRef = useTemplateRef("bar");
|
|
87
|
+
const trackRef = useTemplateRef("track");
|
|
88
|
+
const { play, pause } = usePlayerAudioApi({
|
|
89
|
+
id: mappedInstanceId.value
|
|
90
|
+
});
|
|
91
|
+
const { initialize, destroy, onMouseenter, onMouseleave } = usePlayerControlsApi({
|
|
92
|
+
id: mappedInstanceId.value,
|
|
93
|
+
barRef,
|
|
94
|
+
trackRef
|
|
95
|
+
});
|
|
96
|
+
const { initializeState } = usePlayerState(mappedInstanceId.value);
|
|
97
|
+
const state = initializeState();
|
|
98
|
+
const { playing, waiting, touched, controlsMouseEntered } = toRefs(state);
|
|
99
|
+
const { idle } = useIdle(3e3);
|
|
100
|
+
initialize();
|
|
101
|
+
onBeforeUnmount(() => {
|
|
102
|
+
destroy();
|
|
103
|
+
});
|
|
104
|
+
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
105
|
+
provide(MagicPlayerTrackRef, trackRef);
|
|
106
|
+
provide(MagicPlayerBarRef, barRef);
|
|
128
107
|
</script>
|
|
@@ -3,8 +3,9 @@ import IconPause from './icons/Pause.vue.js';
|
|
|
3
3
|
interface MagicAudioPlayerControlsProps {
|
|
4
4
|
instanceId?: string;
|
|
5
5
|
}
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
6
|
+
declare const play: () => void, pause: () => void;
|
|
7
|
+
declare const onMouseenter: () => void, onMouseleave: () => void;
|
|
8
|
+
declare const playing: import("vue").Ref<boolean, boolean>, waiting: import("vue").Ref<boolean, boolean>, touched: import("vue").Ref<boolean, boolean>, controlsMouseEntered: import("vue").Ref<boolean, boolean>;
|
|
8
9
|
declare const idle: import("vue").Ref<boolean, boolean>;
|
|
9
10
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
10
11
|
declare var __VLS_1: {}, __VLS_6: {};
|
|
@@ -16,12 +17,14 @@ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$
|
|
|
16
17
|
declare const __VLS_self: import("vue").DefineComponent<MagicAudioPlayerControlsProps, {
|
|
17
18
|
IconPlay: typeof IconPlay;
|
|
18
19
|
IconPause: typeof IconPause;
|
|
19
|
-
playing: typeof playing;
|
|
20
|
-
waiting: typeof waiting;
|
|
21
20
|
play: typeof play;
|
|
22
21
|
pause: typeof pause;
|
|
22
|
+
onMouseenter: typeof onMouseenter;
|
|
23
|
+
onMouseleave: typeof onMouseleave;
|
|
24
|
+
playing: typeof playing;
|
|
25
|
+
waiting: typeof waiting;
|
|
23
26
|
touched: typeof touched;
|
|
24
|
-
|
|
27
|
+
controlsMouseEntered: typeof controlsMouseEntered;
|
|
25
28
|
idle: typeof idle;
|
|
26
29
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicAudioPlayerControlsProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
30
|
declare const __VLS_component: import("vue").DefineComponent<MagicAudioPlayerControlsProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicAudioPlayerControlsProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -1,47 +1,40 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="magic-player-display-time">
|
|
3
|
+
{{ stringifiedTime }}
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { computed, inject, toRefs } from "vue";
|
|
7
9
|
import { formatTime } from "@maas/vue-equipment/utils";
|
|
10
|
+
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
8
11
|
import { MagicPlayerInstanceId } from "../symbols";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
return (_ctx, _cache) => {
|
|
37
|
-
return _openBlock(), _createElementBlock(
|
|
38
|
-
"div",
|
|
39
|
-
_hoisted_1,
|
|
40
|
-
_toDisplayString(stringifiedTime.value),
|
|
41
|
-
1
|
|
42
|
-
/* TEXT */
|
|
43
|
-
);
|
|
44
|
-
};
|
|
12
|
+
const { type = "current" } = defineProps({
|
|
13
|
+
type: {
|
|
14
|
+
type: String,
|
|
15
|
+
required: false
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const instanceId = inject(MagicPlayerInstanceId);
|
|
19
|
+
if (!instanceId) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"MagicPlayerDisplayTime must be nested inside MagicPlayerVideoControls or MagicPlayerAudioControls."
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
const { initializeState } = usePlayerState(instanceId);
|
|
25
|
+
const state = initializeState();
|
|
26
|
+
const { currentTime, duration } = toRefs(state);
|
|
27
|
+
const remainingTime = computed(() => duration.value - currentTime.value);
|
|
28
|
+
const stringifiedTime = computed(() => {
|
|
29
|
+
switch (type) {
|
|
30
|
+
case "current":
|
|
31
|
+
return formatTime(currentTime.value, currentTime.value);
|
|
32
|
+
case "remaining":
|
|
33
|
+
return `-${formatTime(remainingTime.value, remainingTime.value)}`;
|
|
34
|
+
case "duration":
|
|
35
|
+
return formatTime(duration.value, duration.value);
|
|
36
|
+
default:
|
|
37
|
+
return "";
|
|
45
38
|
}
|
|
46
39
|
});
|
|
47
40
|
</script>
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:style="{
|
|
4
|
+
width: `${thumbWidth}px`,
|
|
5
|
+
height: `${thumbHeight}px`
|
|
6
|
+
}"
|
|
7
|
+
class="magic-player-mux-popover"
|
|
8
|
+
>
|
|
9
|
+
<canvas
|
|
10
|
+
ref="canvas"
|
|
11
|
+
:width="storyboard?.tile_width"
|
|
12
|
+
:height="storyboard?.tile_height"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
5
18
|
import {
|
|
19
|
+
toRefs,
|
|
6
20
|
shallowRef,
|
|
7
21
|
onMounted,
|
|
8
22
|
watch,
|
|
@@ -11,113 +25,92 @@ import {
|
|
|
11
25
|
useTemplateRef
|
|
12
26
|
} from "vue";
|
|
13
27
|
import { useDevicePixelRatio } from "@vueuse/core";
|
|
14
|
-
import {
|
|
28
|
+
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
15
29
|
import { MagicPlayerInstanceId, MagicPlayerOptionsKey } from "../symbols";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
setup(__props) {
|
|
22
|
-
const instanceId = inject(MagicPlayerInstanceId, void 0);
|
|
23
|
-
const injectedOptions = inject(MagicPlayerOptionsKey, void 0);
|
|
24
|
-
if (!instanceId || !injectedOptions) {
|
|
25
|
-
throw new Error(
|
|
26
|
-
"MagicPlayerMuxPopover must be nested inside MagicPlayerVideoControls."
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
const { seekedTime } = usePlayerControlsApi({ id: instanceId });
|
|
30
|
-
const { pixelRatio } = useDevicePixelRatio();
|
|
31
|
-
const canvasRef = useTemplateRef("canvas");
|
|
32
|
-
const storyboard = shallowRef();
|
|
33
|
-
let context = void 0;
|
|
34
|
-
let image = void 0;
|
|
35
|
-
const thumbWidth = computed(() => {
|
|
36
|
-
if (!storyboard.value) return 0;
|
|
37
|
-
return storyboard.value.tile_width / pixelRatio.value;
|
|
38
|
-
});
|
|
39
|
-
const thumbHeight = computed(() => {
|
|
40
|
-
if (!storyboard.value) return 0;
|
|
41
|
-
return storyboard.value.tile_height / pixelRatio.value;
|
|
42
|
-
});
|
|
43
|
-
function getMuxId(url) {
|
|
44
|
-
const match = url?.match(/mux\.com\/([^\/]+)/);
|
|
45
|
-
return match?.[1]?.replace(/\.(m3u8|mp4)$/, "");
|
|
46
|
-
}
|
|
47
|
-
async function init() {
|
|
48
|
-
const parsedPlaybackId = getMuxId(injectedOptions?.src);
|
|
49
|
-
const mappedPlaybackId = __props.playbackId ?? parsedPlaybackId;
|
|
50
|
-
if (!mappedPlaybackId) {
|
|
51
|
-
console.error(
|
|
52
|
-
"MagicPlayerMuxPopover must be nested inside MagicPlayerProvider or a playbackId must be provided"
|
|
53
|
-
);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
storyboard.value = await fetch(
|
|
58
|
-
`https://image.mux.com/${mappedPlaybackId}/storyboard.json`
|
|
59
|
-
).then((res) => res.json());
|
|
60
|
-
if (!storyboard.value) throw new Error();
|
|
61
|
-
image = new Image();
|
|
62
|
-
image.src = storyboard.value.url;
|
|
63
|
-
await image.decode();
|
|
64
|
-
context = canvasRef.value?.getContext("2d");
|
|
65
|
-
context?.drawImage(image, 0, 0);
|
|
66
|
-
} catch (e) {
|
|
67
|
-
console.error("Can not initialize timeine preview.", e);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function drawFrame(time) {
|
|
71
|
-
if (!storyboard.value || !context || !image) return;
|
|
72
|
-
const { tile_height, tile_width, tiles } = storyboard.value;
|
|
73
|
-
let closestIndex = -1;
|
|
74
|
-
let minDifference = Infinity;
|
|
75
|
-
for (let i = 0; i < tiles.length; i++) {
|
|
76
|
-
const { start } = tiles[i];
|
|
77
|
-
const difference = Math.abs(start - time);
|
|
78
|
-
if (difference < minDifference) {
|
|
79
|
-
minDifference = difference;
|
|
80
|
-
closestIndex = i;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const tile = tiles[closestIndex];
|
|
84
|
-
context.drawImage(
|
|
85
|
-
image,
|
|
86
|
-
tile.x,
|
|
87
|
-
tile.y,
|
|
88
|
-
tile_width,
|
|
89
|
-
tile_height,
|
|
90
|
-
0,
|
|
91
|
-
0,
|
|
92
|
-
tile_width,
|
|
93
|
-
tile_height
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
onMounted(init);
|
|
97
|
-
watch(() => seekedTime?.value, drawFrame);
|
|
98
|
-
return (_ctx, _cache) => {
|
|
99
|
-
return _openBlock(), _createElementBlock(
|
|
100
|
-
"div",
|
|
101
|
-
{
|
|
102
|
-
style: _normalizeStyle({
|
|
103
|
-
width: `${thumbWidth.value}px`,
|
|
104
|
-
height: `${thumbHeight.value}px`
|
|
105
|
-
}),
|
|
106
|
-
class: "magic-player-mux-popover"
|
|
107
|
-
},
|
|
108
|
-
[
|
|
109
|
-
_createElementVNode("canvas", {
|
|
110
|
-
ref: "canvas",
|
|
111
|
-
width: storyboard.value?.tile_width,
|
|
112
|
-
height: storyboard.value?.tile_height
|
|
113
|
-
}, null, 8, _hoisted_1)
|
|
114
|
-
],
|
|
115
|
-
4
|
|
116
|
-
/* STYLE */
|
|
117
|
-
);
|
|
118
|
-
};
|
|
30
|
+
const { playbackId } = defineProps({
|
|
31
|
+
playbackId: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false
|
|
119
34
|
}
|
|
120
35
|
});
|
|
36
|
+
const instanceId = inject(MagicPlayerInstanceId, void 0);
|
|
37
|
+
const injectedOptions = inject(MagicPlayerOptionsKey, void 0);
|
|
38
|
+
if (!instanceId || !injectedOptions) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
"MagicPlayerMuxPopover must be nested inside MagicPlayerVideoControls."
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const { initializeState } = usePlayerState(instanceId);
|
|
44
|
+
const state = initializeState();
|
|
45
|
+
const { seekedTime } = toRefs(state);
|
|
46
|
+
const { pixelRatio } = useDevicePixelRatio();
|
|
47
|
+
const canvasRef = useTemplateRef("canvas");
|
|
48
|
+
const storyboard = shallowRef();
|
|
49
|
+
let context = void 0;
|
|
50
|
+
let image = void 0;
|
|
51
|
+
const thumbWidth = computed(() => {
|
|
52
|
+
if (!storyboard.value) return 0;
|
|
53
|
+
return storyboard.value.tile_width / pixelRatio.value;
|
|
54
|
+
});
|
|
55
|
+
const thumbHeight = computed(() => {
|
|
56
|
+
if (!storyboard.value) return 0;
|
|
57
|
+
return storyboard.value.tile_height / pixelRatio.value;
|
|
58
|
+
});
|
|
59
|
+
function getMuxId(url) {
|
|
60
|
+
const match = url?.match(/mux\.com\/([^\/]+)/);
|
|
61
|
+
return match?.[1]?.replace(/\.(m3u8|mp4)$/, "");
|
|
62
|
+
}
|
|
63
|
+
async function init() {
|
|
64
|
+
const parsedPlaybackId = getMuxId(injectedOptions?.src);
|
|
65
|
+
const mappedPlaybackId = playbackId ?? parsedPlaybackId;
|
|
66
|
+
if (!mappedPlaybackId) {
|
|
67
|
+
console.error(
|
|
68
|
+
"MagicPlayerMuxPopover must be nested inside MagicPlayerProvider or a playbackId must be provided"
|
|
69
|
+
);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
storyboard.value = await fetch(
|
|
74
|
+
`https://image.mux.com/${mappedPlaybackId}/storyboard.json`
|
|
75
|
+
).then((res) => res.json());
|
|
76
|
+
if (!storyboard.value) throw new Error();
|
|
77
|
+
image = new Image();
|
|
78
|
+
image.src = storyboard.value.url;
|
|
79
|
+
await image.decode();
|
|
80
|
+
context = canvasRef.value?.getContext("2d");
|
|
81
|
+
context?.drawImage(image, 0, 0);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.error("Can not initialize timeine preview.", e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function drawFrame(time) {
|
|
87
|
+
if (!storyboard.value || !context || !image) return;
|
|
88
|
+
const { tile_height, tile_width, tiles } = storyboard.value;
|
|
89
|
+
let closestIndex = -1;
|
|
90
|
+
let minDifference = Infinity;
|
|
91
|
+
for (let i = 0; i < tiles.length; i++) {
|
|
92
|
+
const { start } = tiles[i];
|
|
93
|
+
const difference = Math.abs(start - time);
|
|
94
|
+
if (difference < minDifference) {
|
|
95
|
+
minDifference = difference;
|
|
96
|
+
closestIndex = i;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const tile = tiles[closestIndex];
|
|
100
|
+
context.drawImage(
|
|
101
|
+
image,
|
|
102
|
+
tile.x,
|
|
103
|
+
tile.y,
|
|
104
|
+
tile_width,
|
|
105
|
+
tile_height,
|
|
106
|
+
0,
|
|
107
|
+
0,
|
|
108
|
+
tile_width,
|
|
109
|
+
tile_height
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
onMounted(init);
|
|
113
|
+
watch(() => seekedTime?.value, drawFrame);
|
|
121
114
|
</script>
|
|
122
115
|
|
|
123
116
|
<style>
|