@maas/vue-equipment 1.0.0-beta.13 → 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/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 +49 -65
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +87 -129
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +33 -41
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +99 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +47 -75
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue +16 -31
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +43 -44
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +52 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +65 -72
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +154 -225
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +1 -1
- 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 +1 -1
- 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
|
@@ -1,32 +1,58 @@
|
|
|
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
|
-
|
|
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>
|
|
30
56
|
import {
|
|
31
57
|
toRefs,
|
|
32
58
|
computed,
|
|
@@ -39,111 +65,43 @@ import { useIdle } from "@vueuse/core";
|
|
|
39
65
|
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
40
66
|
import { usePlayerAudioApi } from "../composables/private/usePlayerAudioApi";
|
|
41
67
|
import { usePlayerControlsApi } from "../composables/private/usePlayerControlsApi";
|
|
42
|
-
import IconPlay from "./icons/Play.vue";
|
|
43
|
-
import IconPause from "./icons/Pause.vue";
|
|
44
68
|
import {
|
|
45
69
|
MagicPlayerInstanceId,
|
|
46
70
|
MagicPlayerTrackRef,
|
|
47
71
|
MagicPlayerBarRef
|
|
48
72
|
} from "../symbols";
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
setup(__props) {
|
|
55
|
-
const injectedInstanceId = inject(MagicPlayerInstanceId, void 0);
|
|
56
|
-
const mappedInstanceId = computed(() => __props.instanceId ?? injectedInstanceId);
|
|
57
|
-
if (!mappedInstanceId.value) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
"MagicAudioPlayerControls must be nested inside MagicAudioPlayer or an instanceId must be provided."
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
const barRef = useTemplateRef("bar");
|
|
63
|
-
const trackRef = useTemplateRef("track");
|
|
64
|
-
const { play, pause } = usePlayerAudioApi({
|
|
65
|
-
id: mappedInstanceId.value
|
|
66
|
-
});
|
|
67
|
-
const { initialize, destroy, onMouseenter, onMouseleave } = usePlayerControlsApi({
|
|
68
|
-
id: mappedInstanceId.value,
|
|
69
|
-
barRef,
|
|
70
|
-
trackRef
|
|
71
|
-
});
|
|
72
|
-
const { initializeState } = usePlayerState(mappedInstanceId.value);
|
|
73
|
-
const state = initializeState();
|
|
74
|
-
const { playing, waiting, touched, controlsMouseEntered } = toRefs(state);
|
|
75
|
-
const { idle } = useIdle(3e3);
|
|
76
|
-
initialize();
|
|
77
|
-
onBeforeUnmount(() => {
|
|
78
|
-
destroy();
|
|
79
|
-
});
|
|
80
|
-
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
81
|
-
provide(MagicPlayerTrackRef, trackRef);
|
|
82
|
-
provide(MagicPlayerBarRef, barRef);
|
|
83
|
-
return (_ctx, _cache) => {
|
|
84
|
-
const _component_magic_player_display_time = _resolveComponent("magic-player-display-time");
|
|
85
|
-
const _component_magic_player_timeline = _resolveComponent("magic-player-timeline");
|
|
86
|
-
return _openBlock(), _createElementBlock("div", {
|
|
87
|
-
class: "magic-player-audio-controls",
|
|
88
|
-
"data-touched": _unref(touched),
|
|
89
|
-
"data-playing": _unref(playing),
|
|
90
|
-
"data-paused": !_unref(playing),
|
|
91
|
-
"data-waiting": _unref(waiting),
|
|
92
|
-
"data-idle": _unref(idle),
|
|
93
|
-
"data-hover": _unref(controlsMouseEntered),
|
|
94
|
-
onMouseenter: _cache[2] || (_cache[2] = //@ts-ignore
|
|
95
|
-
(...args) => _unref(onMouseenter) && _unref(onMouseenter)(...args)),
|
|
96
|
-
onMouseleave: _cache[3] || (_cache[3] = //@ts-ignore
|
|
97
|
-
(...args) => _unref(onMouseleave) && _unref(onMouseleave)(...args))
|
|
98
|
-
}, [
|
|
99
|
-
_createElementVNode("div", _hoisted_2, [
|
|
100
|
-
_createElementVNode(
|
|
101
|
-
"div",
|
|
102
|
-
_hoisted_3,
|
|
103
|
-
[
|
|
104
|
-
_createElementVNode("div", _hoisted_4, [
|
|
105
|
-
!_unref(playing) ? (_openBlock(), _createElementBlock("button", {
|
|
106
|
-
key: 0,
|
|
107
|
-
onClick: _cache[0] || (_cache[0] = //@ts-ignore
|
|
108
|
-
(...args) => _unref(play) && _unref(play)(...args))
|
|
109
|
-
}, [
|
|
110
|
-
_renderSlot(_ctx.$slots, "playIcon", {}, () => [
|
|
111
|
-
_createVNode(IconPlay)
|
|
112
|
-
])
|
|
113
|
-
])) : (_openBlock(), _createElementBlock("button", {
|
|
114
|
-
key: 1,
|
|
115
|
-
onClick: _cache[1] || (_cache[1] = //@ts-ignore
|
|
116
|
-
(...args) => _unref(pause) && _unref(pause)(...args))
|
|
117
|
-
}, [
|
|
118
|
-
_renderSlot(_ctx.$slots, "pauseIcon", {}, () => [
|
|
119
|
-
_createVNode(IconPause)
|
|
120
|
-
])
|
|
121
|
-
]))
|
|
122
|
-
]),
|
|
123
|
-
_createElementVNode("div", _hoisted_5, [
|
|
124
|
-
_createVNode(_component_magic_player_display_time, { type: "current" })
|
|
125
|
-
]),
|
|
126
|
-
_createElementVNode("div", _hoisted_6, [
|
|
127
|
-
_createElementVNode(
|
|
128
|
-
"div",
|
|
129
|
-
_hoisted_7,
|
|
130
|
-
[
|
|
131
|
-
_createVNode(_component_magic_player_timeline)
|
|
132
|
-
],
|
|
133
|
-
512
|
|
134
|
-
/* NEED_PATCH */
|
|
135
|
-
)
|
|
136
|
-
]),
|
|
137
|
-
_createElementVNode("div", _hoisted_8, [
|
|
138
|
-
_createVNode(_component_magic_player_display_time, { type: "duration" })
|
|
139
|
-
])
|
|
140
|
-
],
|
|
141
|
-
512
|
|
142
|
-
/* NEED_PATCH */
|
|
143
|
-
)
|
|
144
|
-
])
|
|
145
|
-
], 40, _hoisted_1);
|
|
146
|
-
};
|
|
73
|
+
const { instanceId } = defineProps({
|
|
74
|
+
instanceId: {
|
|
75
|
+
type: String,
|
|
76
|
+
required: false
|
|
147
77
|
}
|
|
148
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);
|
|
149
107
|
</script>
|
|
@@ -1,48 +1,40 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="magic-player-display-time">
|
|
3
|
+
{{ stringifiedTime }}
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
5
8
|
import { computed, inject, toRefs } from "vue";
|
|
6
9
|
import { formatTime } from "@maas/vue-equipment/utils";
|
|
7
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
|
-
});
|
|
37
|
-
return (_ctx, _cache) => {
|
|
38
|
-
return _openBlock(), _createElementBlock(
|
|
39
|
-
"div",
|
|
40
|
-
_hoisted_1,
|
|
41
|
-
_toDisplayString(stringifiedTime.value),
|
|
42
|
-
1
|
|
43
|
-
/* TEXT */
|
|
44
|
-
);
|
|
45
|
-
};
|
|
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 "";
|
|
46
38
|
}
|
|
47
39
|
});
|
|
48
40
|
</script>
|
|
@@ -1,7 +1,20 @@
|
|
|
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 {
|
|
6
19
|
toRefs,
|
|
7
20
|
shallowRef,
|
|
@@ -14,113 +27,90 @@ import {
|
|
|
14
27
|
import { useDevicePixelRatio } from "@vueuse/core";
|
|
15
28
|
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
16
29
|
import { MagicPlayerInstanceId, MagicPlayerOptionsKey } from "../symbols";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
setup(__props) {
|
|
23
|
-
const instanceId = inject(MagicPlayerInstanceId, void 0);
|
|
24
|
-
const injectedOptions = inject(MagicPlayerOptionsKey, void 0);
|
|
25
|
-
if (!instanceId || !injectedOptions) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
"MagicPlayerMuxPopover must be nested inside MagicPlayerVideoControls."
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
const { initializeState } = usePlayerState(instanceId);
|
|
31
|
-
const state = initializeState();
|
|
32
|
-
const { seekedTime } = toRefs(state);
|
|
33
|
-
const { pixelRatio } = useDevicePixelRatio();
|
|
34
|
-
const canvasRef = useTemplateRef("canvas");
|
|
35
|
-
const storyboard = shallowRef();
|
|
36
|
-
let context = void 0;
|
|
37
|
-
let image = void 0;
|
|
38
|
-
const thumbWidth = computed(() => {
|
|
39
|
-
if (!storyboard.value) return 0;
|
|
40
|
-
return storyboard.value.tile_width / pixelRatio.value;
|
|
41
|
-
});
|
|
42
|
-
const thumbHeight = computed(() => {
|
|
43
|
-
if (!storyboard.value) return 0;
|
|
44
|
-
return storyboard.value.tile_height / pixelRatio.value;
|
|
45
|
-
});
|
|
46
|
-
function getMuxId(url) {
|
|
47
|
-
const match = url?.match(/mux\.com\/([^\/]+)/);
|
|
48
|
-
return match?.[1]?.replace(/\.(m3u8|mp4)$/, "");
|
|
49
|
-
}
|
|
50
|
-
async function init() {
|
|
51
|
-
const parsedPlaybackId = getMuxId(injectedOptions?.src);
|
|
52
|
-
const mappedPlaybackId = __props.playbackId ?? parsedPlaybackId;
|
|
53
|
-
if (!mappedPlaybackId) {
|
|
54
|
-
console.error(
|
|
55
|
-
"MagicPlayerMuxPopover must be nested inside MagicPlayerProvider or a playbackId must be provided"
|
|
56
|
-
);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
storyboard.value = await fetch(
|
|
61
|
-
`https://image.mux.com/${mappedPlaybackId}/storyboard.json`
|
|
62
|
-
).then((res) => res.json());
|
|
63
|
-
if (!storyboard.value) throw new Error();
|
|
64
|
-
image = new Image();
|
|
65
|
-
image.src = storyboard.value.url;
|
|
66
|
-
await image.decode();
|
|
67
|
-
context = canvasRef.value?.getContext("2d");
|
|
68
|
-
context?.drawImage(image, 0, 0);
|
|
69
|
-
} catch (e) {
|
|
70
|
-
console.error("Can not initialize timeine preview.", e);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function drawFrame(time) {
|
|
74
|
-
if (!storyboard.value || !context || !image) return;
|
|
75
|
-
const { tile_height, tile_width, tiles } = storyboard.value;
|
|
76
|
-
let closestIndex = -1;
|
|
77
|
-
let minDifference = Infinity;
|
|
78
|
-
for (let i = 0; i < tiles.length; i++) {
|
|
79
|
-
const { start } = tiles[i];
|
|
80
|
-
const difference = Math.abs(start - time);
|
|
81
|
-
if (difference < minDifference) {
|
|
82
|
-
minDifference = difference;
|
|
83
|
-
closestIndex = i;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const tile = tiles[closestIndex];
|
|
87
|
-
context.drawImage(
|
|
88
|
-
image,
|
|
89
|
-
tile.x,
|
|
90
|
-
tile.y,
|
|
91
|
-
tile_width,
|
|
92
|
-
tile_height,
|
|
93
|
-
0,
|
|
94
|
-
0,
|
|
95
|
-
tile_width,
|
|
96
|
-
tile_height
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
onMounted(init);
|
|
100
|
-
watch(() => seekedTime?.value, drawFrame);
|
|
101
|
-
return (_ctx, _cache) => {
|
|
102
|
-
return _openBlock(), _createElementBlock(
|
|
103
|
-
"div",
|
|
104
|
-
{
|
|
105
|
-
style: _normalizeStyle({
|
|
106
|
-
width: `${thumbWidth.value}px`,
|
|
107
|
-
height: `${thumbHeight.value}px`
|
|
108
|
-
}),
|
|
109
|
-
class: "magic-player-mux-popover"
|
|
110
|
-
},
|
|
111
|
-
[
|
|
112
|
-
_createElementVNode("canvas", {
|
|
113
|
-
ref: "canvas",
|
|
114
|
-
width: storyboard.value?.tile_width,
|
|
115
|
-
height: storyboard.value?.tile_height
|
|
116
|
-
}, null, 8, _hoisted_1)
|
|
117
|
-
],
|
|
118
|
-
4
|
|
119
|
-
/* STYLE */
|
|
120
|
-
);
|
|
121
|
-
};
|
|
30
|
+
const { playbackId } = defineProps({
|
|
31
|
+
playbackId: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: false
|
|
122
34
|
}
|
|
123
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);
|
|
124
114
|
</script>
|
|
125
115
|
|
|
126
116
|
<style>
|
|
@@ -1,84 +1,56 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="magic-player-overlay"
|
|
4
|
+
:data-playing="playing"
|
|
5
|
+
:data-paused="!playing"
|
|
6
|
+
:data-waiting="waiting"
|
|
7
|
+
:data-idle="idle"
|
|
8
|
+
:data-hover="mouseEntered"
|
|
9
|
+
@click.stop="togglePlay"
|
|
10
|
+
>
|
|
11
|
+
<slot>
|
|
12
|
+
<template v-if="waiting">
|
|
13
|
+
<button class="magic-player-overlay__button">
|
|
14
|
+
<slot name="waitingIcon">
|
|
15
|
+
<icon-waiting />
|
|
16
|
+
</slot>
|
|
17
|
+
</button>
|
|
18
|
+
</template>
|
|
19
|
+
<template v-else>
|
|
20
|
+
<button v-if="!playing" class="magic-player-overlay__button">
|
|
21
|
+
<slot name="playIcon">
|
|
22
|
+
<icon-play />
|
|
23
|
+
</slot>
|
|
24
|
+
</button>
|
|
25
|
+
<button v-else class="magic-player-overlay__button">
|
|
26
|
+
<slot name="pauseIcon">
|
|
27
|
+
<icon-pause />
|
|
28
|
+
</slot>
|
|
29
|
+
</button>
|
|
30
|
+
</template>
|
|
31
|
+
</slot>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script setup>
|
|
17
36
|
import { inject, toRefs } from "vue";
|
|
18
37
|
import { useIdle } from "@vueuse/core";
|
|
19
|
-
import IconPlay from "./icons/Play.vue";
|
|
20
|
-
import IconPause from "./icons/Pause.vue";
|
|
21
|
-
import IconWaiting from "./icons/Waiting.vue";
|
|
22
38
|
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
23
39
|
import { usePlayerVideoApi } from "../composables/private/usePlayerVideoApi";
|
|
24
40
|
import { MagicPlayerInstanceId } from "../symbols";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const { mouseEntered, playing, waiting } = toRefs(state);
|
|
37
|
-
const { togglePlay } = usePlayerVideoApi({
|
|
38
|
-
id: instanceId
|
|
39
|
-
});
|
|
40
|
-
const { idle } = useIdle(3e3);
|
|
41
|
-
return (_ctx, _cache) => {
|
|
42
|
-
return _openBlock(), _createElementBlock("div", {
|
|
43
|
-
class: "magic-player-overlay",
|
|
44
|
-
"data-playing": _unref(playing),
|
|
45
|
-
"data-paused": !_unref(playing),
|
|
46
|
-
"data-waiting": _unref(waiting),
|
|
47
|
-
"data-idle": _unref(idle),
|
|
48
|
-
"data-hover": _unref(mouseEntered),
|
|
49
|
-
onClick: _cache[0] || (_cache[0] = _withModifiers(
|
|
50
|
-
//@ts-ignore
|
|
51
|
-
(...args) => _unref(togglePlay) && _unref(togglePlay)(...args),
|
|
52
|
-
["stop"]
|
|
53
|
-
))
|
|
54
|
-
}, [
|
|
55
|
-
_renderSlot(_ctx.$slots, "default", {}, () => [
|
|
56
|
-
_unref(waiting) ? (_openBlock(), _createElementBlock("button", _hoisted_2, [
|
|
57
|
-
_renderSlot(_ctx.$slots, "waitingIcon", {}, () => [
|
|
58
|
-
_createVNode(IconWaiting)
|
|
59
|
-
])
|
|
60
|
-
])) : (_openBlock(), _createElementBlock(
|
|
61
|
-
_Fragment,
|
|
62
|
-
{ key: 1 },
|
|
63
|
-
[
|
|
64
|
-
!_unref(playing) ? (_openBlock(), _createElementBlock("button", _hoisted_3, [
|
|
65
|
-
_renderSlot(_ctx.$slots, "playIcon", {}, () => [
|
|
66
|
-
_createVNode(IconPlay)
|
|
67
|
-
])
|
|
68
|
-
])) : (_openBlock(), _createElementBlock("button", _hoisted_4, [
|
|
69
|
-
_renderSlot(_ctx.$slots, "pauseIcon", {}, () => [
|
|
70
|
-
_createVNode(IconPause)
|
|
71
|
-
])
|
|
72
|
-
]))
|
|
73
|
-
],
|
|
74
|
-
64
|
|
75
|
-
/* STABLE_FRAGMENT */
|
|
76
|
-
))
|
|
77
|
-
])
|
|
78
|
-
], 8, _hoisted_1);
|
|
79
|
-
};
|
|
80
|
-
}
|
|
41
|
+
const instanceId = inject(MagicPlayerInstanceId, void 0);
|
|
42
|
+
if (!instanceId) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
"MagicPlayerOverlay must be nested inside MagicPlayerProvider."
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const { initializeState } = usePlayerState(instanceId);
|
|
48
|
+
const state = initializeState();
|
|
49
|
+
const { mouseEntered, playing, waiting } = toRefs(state);
|
|
50
|
+
const { togglePlay } = usePlayerVideoApi({
|
|
51
|
+
id: instanceId
|
|
81
52
|
});
|
|
53
|
+
const { idle } = useIdle(3e3);
|
|
82
54
|
</script>
|
|
83
55
|
|
|
84
56
|
<style>
|