@maas/vue-equipment 0.11.6 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +1 -1
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.d.ts +2 -2
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.mjs +4 -4
- package/dist/plugins/MagicModal/src/composables/useModalApi.mjs +3 -3
- package/dist/plugins/MagicPlayer/index.d.ts +2 -7
- package/dist/plugins/MagicPlayer/index.mjs +4 -25
- package/dist/plugins/MagicPlayer/nuxt.mjs +1 -13
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue +21 -16
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue.d.ts +10 -29
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue +73 -91
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue.d.ts +16 -16
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +11 -11
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue.d.ts +8 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +97 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue.d.ts +21 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +25 -15
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue.d.ts +11 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Waiting.vue +1 -1
- package/dist/plugins/MagicPlayer/src/composables/{useControlsApi.d.ts → private/useControlsApi.d.ts} +8 -8
- package/dist/plugins/MagicPlayer/src/composables/{useControlsApi.mjs → private/useControlsApi.mjs} +23 -20
- package/dist/plugins/MagicPlayer/src/composables/{useMediaApi.d.ts → private/useMediaApi.d.ts} +2 -2
- package/dist/plugins/MagicPlayer/src/composables/{useMediaApi.mjs → private/useMediaApi.mjs} +29 -28
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerInternalApi.d.ts +18 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerInternalApi.mjs +63 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerStore.d.ts +18 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerStore.mjs +36 -0
- package/dist/plugins/MagicPlayer/src/composables/{useRuntimeSourceProvider.d.ts → private/useRuntimeSourceProvider.d.ts} +1 -3
- package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.d.ts +2 -17
- package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.mjs +62 -43
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +14 -3
- package/package.json +1 -1
- package/dist/plugins/MagicPlayer/src/composables/useControls.d.ts +0 -8
- package/dist/plugins/MagicPlayer/src/composables/useControls.mjs +0 -15
- package/dist/plugins/MagicPlayer/src/composables/usePlayer.d.ts +0 -12
- package/dist/plugins/MagicPlayer/src/composables/usePlayer.mjs +0 -33
- package/dist/plugins/MagicPlayer/src/symbols/index.d.ts +0 -45
- package/dist/plugins/MagicPlayer/src/symbols/index.mjs +0 -10
- /package/dist/plugins/MagicPlayer/src/composables/{useRuntimeSourceProvider.mjs → private/useRuntimeSourceProvider.mjs} +0 -0
package/dist/nuxt/module.json
CHANGED
package/dist/nuxt/module.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
2
|
let modalStore = ref([]);
|
|
3
3
|
export function useModalStore() {
|
|
4
|
-
function
|
|
4
|
+
function addInstance(id) {
|
|
5
5
|
modalStore.value.push(id);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function removeInstance(id) {
|
|
8
8
|
modalStore.value = modalStore.value.filter((x) => x !== id);
|
|
9
9
|
}
|
|
10
10
|
return {
|
|
11
11
|
modalStore,
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
addInstance,
|
|
13
|
+
removeInstance
|
|
14
14
|
};
|
|
15
15
|
}
|
|
@@ -14,13 +14,13 @@ export function useModalApi(id, options) {
|
|
|
14
14
|
const mappedOptions = defu(options, defaultOptions);
|
|
15
15
|
const focusTrap = mappedOptions.focusTarget ? useFocusTrap(mappedOptions.focusTarget) : void 0;
|
|
16
16
|
const scrollLock = mappedOptions.scrollLock && typeof window !== "undefined" ? useScrollLock(document.body) : ref(false);
|
|
17
|
-
const { modalStore,
|
|
17
|
+
const { modalStore, addInstance, removeInstance } = useModalStore();
|
|
18
18
|
const isActive = computed(() => modalStore.value.includes(mappedId.value));
|
|
19
19
|
function open() {
|
|
20
|
-
|
|
20
|
+
addInstance(mappedId.value);
|
|
21
21
|
}
|
|
22
22
|
function close() {
|
|
23
|
-
|
|
23
|
+
removeInstance(mappedId.value);
|
|
24
24
|
}
|
|
25
25
|
function trapFocus() {
|
|
26
26
|
if (focusTrap) {
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import type { Plugin } from 'vue';
|
|
2
2
|
import MagicPlayer from './src/components/MagicPlayer.vue.js';
|
|
3
3
|
import MagicPlayerControls from './src/components/MagicPlayerControls.vue.js';
|
|
4
|
+
import MagicPlayerOverlay from './src/components/MagicPlayerOverlay.vue.js';
|
|
4
5
|
import MagicPlayerTimeline from './src/components/MagicPlayerTimeline.vue.js';
|
|
5
6
|
import MagicPlayerMuxPopover from './src/components/MagicPlayerMuxPopover.vue.js';
|
|
6
|
-
import { useMediaApi } from './src/composables/useMediaApi.js';
|
|
7
7
|
import { usePlayerApi } from './src/composables/usePlayerApi.js';
|
|
8
|
-
import { useProvidePlayer, useInjectPlayer } from './src/composables/usePlayer.js';
|
|
9
|
-
import { useProvideControls, useInjectControls } from './src/composables/useControls.js';
|
|
10
|
-
import { useRuntimeSourceProvider } from './src/composables/useRuntimeSourceProvider.js';
|
|
11
|
-
import { MediaApiInjectionKey, PlayerApiInjectionKey, RuntimeSourceProviderInjectionKey, ControlsApiInjectionKey } from './src/symbols.js';
|
|
12
8
|
declare const MagicPlayerPlugin: Plugin;
|
|
13
|
-
export { MagicPlayerPlugin, MagicPlayer, MagicPlayerControls, MagicPlayerTimeline, MagicPlayerMuxPopover,
|
|
14
|
-
export * from './src/symbols.js';
|
|
9
|
+
export { MagicPlayerPlugin, MagicPlayer, MagicPlayerControls, MagicPlayerOverlay, MagicPlayerTimeline, MagicPlayerMuxPopover, usePlayerApi, };
|
|
15
10
|
export type * from './src/types';
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import MagicPlayer from "./src/components/MagicPlayer.vue";
|
|
2
2
|
import MagicPlayerControls from "./src/components/MagicPlayerControls.vue";
|
|
3
|
+
import MagicPlayerOverlay from "./src/components/MagicPlayerOverlay.vue";
|
|
3
4
|
import MagicPlayerTimeline from "./src/components/MagicPlayerTimeline.vue";
|
|
4
5
|
import MagicPlayerMuxPopover from "./src/components/MagicPlayerMuxPopover.vue";
|
|
5
|
-
import { useMediaApi } from "./src/composables/useMediaApi.mjs";
|
|
6
6
|
import { usePlayerApi } from "./src/composables/usePlayerApi.mjs";
|
|
7
|
-
import { useProvidePlayer, useInjectPlayer } from "./src/composables/usePlayer.mjs";
|
|
8
|
-
import {
|
|
9
|
-
useProvideControls,
|
|
10
|
-
useInjectControls
|
|
11
|
-
} from "./src/composables/useControls.mjs";
|
|
12
|
-
import { useRuntimeSourceProvider } from "./src/composables/useRuntimeSourceProvider.mjs";
|
|
13
|
-
import {
|
|
14
|
-
MediaApiInjectionKey,
|
|
15
|
-
PlayerApiInjectionKey,
|
|
16
|
-
RuntimeSourceProviderInjectionKey,
|
|
17
|
-
ControlsApiInjectionKey
|
|
18
|
-
} from "./src/symbols/index.mjs";
|
|
19
7
|
const MagicPlayerPlugin = {
|
|
20
8
|
install: (app) => {
|
|
21
9
|
app.component("MagicPlayer", MagicPlayer);
|
|
22
10
|
app.component("MagicPlayerControls", MagicPlayerControls);
|
|
11
|
+
app.component("MagicPlayerOverlay", MagicPlayerOverlay);
|
|
23
12
|
app.component("MagicPlayerTimeline", MagicPlayerTimeline);
|
|
24
13
|
app.component("MagicPlayerMuxPopover", MagicPlayerMuxPopover);
|
|
25
14
|
}
|
|
@@ -28,18 +17,8 @@ export {
|
|
|
28
17
|
MagicPlayerPlugin,
|
|
29
18
|
MagicPlayer,
|
|
30
19
|
MagicPlayerControls,
|
|
20
|
+
MagicPlayerOverlay,
|
|
31
21
|
MagicPlayerTimeline,
|
|
32
22
|
MagicPlayerMuxPopover,
|
|
33
|
-
|
|
34
|
-
usePlayerApi,
|
|
35
|
-
useRuntimeSourceProvider,
|
|
36
|
-
useProvidePlayer,
|
|
37
|
-
useInjectPlayer,
|
|
38
|
-
useProvideControls,
|
|
39
|
-
useInjectControls,
|
|
40
|
-
MediaApiInjectionKey,
|
|
41
|
-
PlayerApiInjectionKey,
|
|
42
|
-
RuntimeSourceProviderInjectionKey,
|
|
43
|
-
ControlsApiInjectionKey
|
|
23
|
+
usePlayerApi
|
|
44
24
|
};
|
|
45
|
-
export * from "./src/symbols/index.mjs";
|
|
@@ -18,19 +18,7 @@ export default defineNuxtModule({
|
|
|
18
18
|
});
|
|
19
19
|
addImports({
|
|
20
20
|
from: "@maas/vue-equipment/plugins/MagicPlayer",
|
|
21
|
-
name: "
|
|
22
|
-
});
|
|
23
|
-
addImports({
|
|
24
|
-
from: "@maas/vue-equipment/plugins/MagicPlayer",
|
|
25
|
-
name: "useInjectPlayer"
|
|
26
|
-
});
|
|
27
|
-
addImports({
|
|
28
|
-
from: "@maas/vue-equipment/plugins/MagicPlayer",
|
|
29
|
-
name: "useProvideControls"
|
|
30
|
-
});
|
|
31
|
-
addImports({
|
|
32
|
-
from: "@maas/vue-equipment/plugins/MagicPlayer",
|
|
33
|
-
name: "useInjectControls"
|
|
21
|
+
name: "usePlayerApi"
|
|
34
22
|
});
|
|
35
23
|
}
|
|
36
24
|
});
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
ref="playerRef"
|
|
4
|
+
class="magic-player"
|
|
5
|
+
:style="computedStyle"
|
|
6
|
+
@mouseenter="onMouseenter"
|
|
7
|
+
@mouseleave="onMouseleave"
|
|
8
|
+
>
|
|
3
9
|
<video
|
|
4
10
|
ref="videoRef"
|
|
5
11
|
class="magic-player-video"
|
|
@@ -14,13 +20,14 @@
|
|
|
14
20
|
</template>
|
|
15
21
|
|
|
16
22
|
<script setup lang="ts">
|
|
17
|
-
import { ref, computed } from 'vue'
|
|
23
|
+
import { ref, computed, toRefs } from 'vue'
|
|
18
24
|
import { useIntersectionObserver } from '@vueuse/core'
|
|
19
|
-
import {
|
|
25
|
+
import { usePlayerApi } from '../composables/usePlayerApi'
|
|
20
26
|
|
|
21
27
|
import type { SourceType } from './../types'
|
|
22
28
|
|
|
23
29
|
export type MagicPlayerProps = {
|
|
30
|
+
id: string
|
|
24
31
|
srcType?: SourceType
|
|
25
32
|
src: string
|
|
26
33
|
ratio?: string
|
|
@@ -37,19 +44,23 @@ const props = withDefaults(defineProps<MagicPlayerProps>(), {
|
|
|
37
44
|
const playerRef = ref<HTMLDivElement | undefined>(undefined)
|
|
38
45
|
const videoRef = ref<HTMLVideoElement | undefined>(undefined)
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
// Initialize instance
|
|
48
|
+
const { instance } = usePlayerApi({
|
|
49
|
+
id: props.id,
|
|
42
50
|
videoRef: videoRef,
|
|
43
|
-
|
|
51
|
+
playerRef: playerRef,
|
|
44
52
|
srcType: props.srcType,
|
|
53
|
+
src: props.src,
|
|
45
54
|
})
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
const {
|
|
55
|
+
|
|
56
|
+
const { playing } = toRefs(instance.value?.mediaApi)
|
|
57
|
+
const { touched } = toRefs(instance.value?.playerApi)
|
|
58
|
+
const { onMouseenter, onMouseleave } = instance.value?.playerApi
|
|
59
|
+
const { loaded } = toRefs(instance.value?.runtimeProvider)
|
|
49
60
|
|
|
50
61
|
useIntersectionObserver(playerRef, ([{ isIntersecting }]) => {
|
|
51
62
|
if (!isIntersecting && playing.value) {
|
|
52
|
-
pause()
|
|
63
|
+
instance.value.playerApi.pause()
|
|
53
64
|
}
|
|
54
65
|
})
|
|
55
66
|
|
|
@@ -70,12 +81,6 @@ const computedStyle = computed(() => {
|
|
|
70
81
|
: undefined,
|
|
71
82
|
}
|
|
72
83
|
})
|
|
73
|
-
|
|
74
|
-
defineExpose({
|
|
75
|
-
playerApi,
|
|
76
|
-
mediaApi,
|
|
77
|
-
runtimeProvider,
|
|
78
|
-
})
|
|
79
84
|
</script>
|
|
80
85
|
|
|
81
86
|
<style lang="css">
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SourceType } from './../types';
|
|
2
2
|
export type MagicPlayerProps = {
|
|
3
|
+
id: string;
|
|
3
4
|
srcType?: SourceType;
|
|
4
5
|
src: string;
|
|
5
6
|
ratio?: string;
|
|
@@ -10,6 +11,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
10
11
|
type: import("vue").PropType<boolean>;
|
|
11
12
|
default: boolean;
|
|
12
13
|
};
|
|
14
|
+
id: {
|
|
15
|
+
type: import("vue").PropType<string>;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
13
18
|
srcType: {
|
|
14
19
|
type: import("vue").PropType<SourceType>;
|
|
15
20
|
default: string;
|
|
@@ -23,39 +28,15 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
23
28
|
type: import("vue").PropType<string>;
|
|
24
29
|
default: string;
|
|
25
30
|
};
|
|
26
|
-
}, {
|
|
27
|
-
playerApi: {
|
|
28
|
-
isFullscreen: import("vue").Ref<boolean>;
|
|
29
|
-
touched: import("vue").Ref<boolean>;
|
|
30
|
-
play: () => void;
|
|
31
|
-
pause: () => void;
|
|
32
|
-
togglePlay: () => void;
|
|
33
|
-
seek: (time: number) => void;
|
|
34
|
-
mute: () => void;
|
|
35
|
-
unmute: () => void;
|
|
36
|
-
enterFullscreen: () => Promise<void>;
|
|
37
|
-
exitFullscreen: () => Promise<void>;
|
|
38
|
-
toggleFullscreen: () => Promise<void>;
|
|
39
|
-
};
|
|
40
|
-
mediaApi: {
|
|
41
|
-
currentTime: import("vue").Ref<number>;
|
|
42
|
-
duration: import("vue").Ref<number>;
|
|
43
|
-
waiting: import("vue").Ref<boolean>;
|
|
44
|
-
seeking: import("vue").Ref<boolean>;
|
|
45
|
-
ended: import("vue").Ref<boolean>;
|
|
46
|
-
stalled: import("vue").Ref<boolean>;
|
|
47
|
-
buffered: import("vue").Ref<[number, number][]>;
|
|
48
|
-
playing: import("vue").Ref<boolean>;
|
|
49
|
-
rate: import("vue").Ref<number>;
|
|
50
|
-
volume: import("vue").Ref<number>;
|
|
51
|
-
muted: import("vue").Ref<boolean>;
|
|
52
|
-
};
|
|
53
|
-
runtimeProvider: import("../composables/useRuntimeSourceProvider").UseRuntimeSourceProviderReturn;
|
|
54
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
31
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
55
32
|
fill: {
|
|
56
33
|
type: import("vue").PropType<boolean>;
|
|
57
34
|
default: boolean;
|
|
58
35
|
};
|
|
36
|
+
id: {
|
|
37
|
+
type: import("vue").PropType<string>;
|
|
38
|
+
required: true;
|
|
39
|
+
};
|
|
59
40
|
srcType: {
|
|
60
41
|
type: import("vue").PropType<SourceType>;
|
|
61
42
|
default: string;
|
|
@@ -10,27 +10,10 @@
|
|
|
10
10
|
'-waiting': waiting,
|
|
11
11
|
'-idle': idle,
|
|
12
12
|
'-not-idle': !idle,
|
|
13
|
-
'-hover':
|
|
14
|
-
'-not-hover': !
|
|
13
|
+
'-hover': mouseEntered,
|
|
14
|
+
'-not-hover': !mouseEntered,
|
|
15
15
|
}"
|
|
16
|
-
@mouseenter="isMouseEnter = true"
|
|
17
|
-
@mouseleave="isMouseEnter = false"
|
|
18
16
|
>
|
|
19
|
-
<div class="magic-player-controls__overlay" @click.stop="togglePlay">
|
|
20
|
-
<template v-if="waiting">
|
|
21
|
-
<button>
|
|
22
|
-
<icon-waiting />
|
|
23
|
-
</button>
|
|
24
|
-
</template>
|
|
25
|
-
<template v-else>
|
|
26
|
-
<button v-if="!playing">
|
|
27
|
-
<icon-play />
|
|
28
|
-
</button>
|
|
29
|
-
<button v-else>
|
|
30
|
-
<icon-pause />
|
|
31
|
-
</button>
|
|
32
|
-
</template>
|
|
33
|
-
</div>
|
|
34
17
|
<div class="magic-player-controls__bar">
|
|
35
18
|
<div
|
|
36
19
|
v-if="$slots.seekPopover"
|
|
@@ -44,31 +27,43 @@
|
|
|
44
27
|
<div class="magic-player-controls__bar--inner" ref="barRef">
|
|
45
28
|
<div class="magic-player-controls__item -shrink-0">
|
|
46
29
|
<button v-if="!playing" @click="play">
|
|
47
|
-
<
|
|
30
|
+
<slot name="playIcon">
|
|
31
|
+
<icon-play />
|
|
32
|
+
</slot>
|
|
48
33
|
</button>
|
|
49
34
|
<button v-else @click="pause">
|
|
50
|
-
<
|
|
35
|
+
<slot name="pauseIcon">
|
|
36
|
+
<icon-pause />
|
|
37
|
+
</slot>
|
|
51
38
|
</button>
|
|
52
39
|
</div>
|
|
53
40
|
<div class="magic-player-controls__item -grow">
|
|
54
41
|
<div class="magic-player-controls__timeline" ref="trackRef">
|
|
55
|
-
<magic-player-timeline />
|
|
42
|
+
<magic-player-timeline :id="id" />
|
|
56
43
|
</div>
|
|
57
44
|
</div>
|
|
58
45
|
<div class="magic-player-controls__item -shrink-0">
|
|
59
46
|
<button v-if="muted" @click="unmute">
|
|
60
|
-
<
|
|
47
|
+
<slot name="volumeOffIcon">
|
|
48
|
+
<icon-volume-off />
|
|
49
|
+
</slot>
|
|
61
50
|
</button>
|
|
62
51
|
<button v-else @click="mute">
|
|
63
|
-
<
|
|
52
|
+
<slot name="volumeOnIcon">
|
|
53
|
+
<icon-volume-on />
|
|
54
|
+
</slot>
|
|
64
55
|
</button>
|
|
65
56
|
</div>
|
|
66
57
|
<div class="magic-player-controls__item -shrink-0">
|
|
67
58
|
<button v-if="isFullscreen" @click="exitFullscreen">
|
|
68
|
-
<
|
|
59
|
+
<slot name="fullscreenExitIcon">
|
|
60
|
+
<icon-fullscreen-exit />
|
|
61
|
+
</slot>
|
|
69
62
|
</button>
|
|
70
63
|
<button v-else @click="enterFullscreen">
|
|
71
|
-
<
|
|
64
|
+
<slot name="fullscreenEnterIcon">
|
|
65
|
+
<icon-fullscreen-enter />
|
|
66
|
+
</slot>
|
|
72
67
|
</button>
|
|
73
68
|
</div>
|
|
74
69
|
</div>
|
|
@@ -77,7 +72,7 @@
|
|
|
77
72
|
</template>
|
|
78
73
|
|
|
79
74
|
<script setup lang="ts">
|
|
80
|
-
import { ref } from 'vue'
|
|
75
|
+
import { ref, toRefs } from 'vue'
|
|
81
76
|
import { useIdle } from '@vueuse/core'
|
|
82
77
|
import IconPlay from './icons/Play.vue'
|
|
83
78
|
import IconPause from './icons/Pause.vue'
|
|
@@ -85,59 +80,54 @@ import IconVolumeOn from './icons/VolumeOn.vue'
|
|
|
85
80
|
import IconVolumeOff from './icons/VolumeOff.vue'
|
|
86
81
|
import IconFullscreenEnter from './icons/FullscreenEnter.vue'
|
|
87
82
|
import IconFullscreenExit from './icons/FullscreenExit.vue'
|
|
88
|
-
import
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
import { usePlayerApi } from '../composables/usePlayerApi'
|
|
84
|
+
|
|
85
|
+
interface Props {
|
|
86
|
+
id: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const props = defineProps<Props>()
|
|
91
90
|
|
|
92
91
|
const barRef = ref<HTMLDivElement | undefined>(undefined)
|
|
93
92
|
const trackRef = ref<HTMLDivElement | undefined>(undefined)
|
|
94
93
|
const popoverRef = ref<HTMLDivElement | undefined>(undefined)
|
|
95
94
|
|
|
96
|
-
const {
|
|
97
|
-
|
|
95
|
+
const { instance } = usePlayerApi({
|
|
96
|
+
id: props.id,
|
|
98
97
|
barRef: barRef,
|
|
99
98
|
trackRef: trackRef,
|
|
100
99
|
popoverRef: popoverRef,
|
|
101
100
|
})
|
|
102
101
|
|
|
103
|
-
const { playing,
|
|
104
|
-
const {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
pause,
|
|
109
|
-
togglePlay,
|
|
110
|
-
mute,
|
|
111
|
-
unmute,
|
|
112
|
-
enterFullscreen,
|
|
113
|
-
exitFullscreen,
|
|
114
|
-
} = playerApi
|
|
102
|
+
const { playing, waiting, muted } = toRefs(instance.value?.mediaApi)
|
|
103
|
+
const { touched, mouseEntered, isFullscreen } = toRefs(
|
|
104
|
+
instance.value?.playerApi,
|
|
105
|
+
)
|
|
106
|
+
const { popoverOffsetX, seekedTime } = toRefs(instance.value?.controlsApi)
|
|
115
107
|
|
|
116
|
-
const {
|
|
108
|
+
const { play, pause, mute, unmute, enterFullscreen, exitFullscreen } =
|
|
109
|
+
instance.value.playerApi
|
|
117
110
|
|
|
118
111
|
const { idle } = useIdle(3000)
|
|
119
|
-
const isMouseEnter = ref(false)
|
|
120
|
-
|
|
121
|
-
defineExpose({
|
|
122
|
-
controlsApi,
|
|
123
|
-
})
|
|
124
112
|
</script>
|
|
125
113
|
|
|
126
114
|
<style lang="css">
|
|
127
115
|
:root {
|
|
128
116
|
--magic-player-controls-height: 3rem;
|
|
129
|
-
--magic-player-controls-bottom: 1.5rem;
|
|
130
117
|
--magic-player-controls-padding: 0.75rem;
|
|
118
|
+
--magic-player-controls-bottom: 1.5rem;
|
|
119
|
+
--magic-player-controls-left: 1.5rem;
|
|
120
|
+
--magic-player-controls-width: calc(
|
|
121
|
+
100% - (var(--magic-player-controls-left) * 2)
|
|
122
|
+
);
|
|
131
123
|
--magic-player-controls-gap: 1rem;
|
|
132
124
|
--magic-player-controls-border-radius: 50rem;
|
|
133
125
|
--magic-player-controls-background-color: rgba(32, 32, 32, 0.8);
|
|
134
126
|
--magic-player-controls-backdrop-filter: blur(80px);
|
|
135
127
|
--magic-player-controls-color: rgba(255, 255, 255, 1);
|
|
136
128
|
--magic-player-controls-icon-width: 1.25rem;
|
|
137
|
-
--magic-player-controls-overlay-background-color: rgba(0, 0, 0, 0.3);
|
|
138
|
-
--magic-player-controls-overlay-color: rgba(255, 255, 255, 1);
|
|
139
129
|
--magic-player-controls-transition-duration: 300ms;
|
|
140
|
-
--magic-player-controls-transition-timing-function: ease
|
|
130
|
+
--magic-player-controls-transition-timing-function: ease;
|
|
141
131
|
}
|
|
142
132
|
|
|
143
133
|
@media (max-width: 640px) {
|
|
@@ -151,41 +141,15 @@ defineExpose({
|
|
|
151
141
|
.magic-player-controls {
|
|
152
142
|
position: absolute;
|
|
153
143
|
inset: 0;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
.magic-player-controls__overlay {
|
|
157
|
-
position: absolute;
|
|
158
|
-
inset: 0;
|
|
159
|
-
background-color: var(--magic-player-controls-overlay-background-color);
|
|
160
|
-
color: var(--magic-player-controls-overlay-color);
|
|
161
|
-
transition-duration: 300ms;
|
|
162
|
-
transition-property: opacity;
|
|
163
|
-
transition-timing-function: ease;
|
|
164
|
-
display: flex;
|
|
165
|
-
align-items: center;
|
|
166
|
-
justify-content: center;
|
|
167
|
-
cursor: pointer;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.magic-player-controls__overlay button {
|
|
171
|
-
background-color: transparent;
|
|
172
|
-
color: inherit;
|
|
173
|
-
border: 0;
|
|
174
|
-
border-radius: 0;
|
|
175
|
-
padding: 0;
|
|
176
|
-
outline: none;
|
|
177
|
-
appearance: none;
|
|
178
|
-
cursor: pointer;
|
|
179
|
-
width: 3.5rem;
|
|
180
|
-
height: 3.5rem;
|
|
144
|
+
width: 100%;
|
|
145
|
+
pointer-events: none;
|
|
181
146
|
}
|
|
182
147
|
|
|
183
148
|
.magic-player-controls__bar {
|
|
184
149
|
position: absolute;
|
|
185
|
-
width:
|
|
150
|
+
width: var(--magic-player-controls-width);
|
|
186
151
|
bottom: var(--magic-player-controls-bottom);
|
|
187
|
-
left:
|
|
188
|
-
transform: translateX(-50%);
|
|
152
|
+
left: var(--magic-player-controls-left);
|
|
189
153
|
margin: 0 auto;
|
|
190
154
|
display: flex;
|
|
191
155
|
flex-direction: column;
|
|
@@ -196,6 +160,7 @@ defineExpose({
|
|
|
196
160
|
--magic-player-controls-transition-timing-function
|
|
197
161
|
);
|
|
198
162
|
transition-property: opacity, transform;
|
|
163
|
+
pointer-events: auto;
|
|
199
164
|
}
|
|
200
165
|
|
|
201
166
|
.magic-player-controls__bar--inner {
|
|
@@ -251,15 +216,32 @@ defineExpose({
|
|
|
251
216
|
width: 100%;
|
|
252
217
|
}
|
|
253
218
|
|
|
254
|
-
.magic-player-controls.-playing.-idle
|
|
255
|
-
.magic-player-
|
|
256
|
-
.magic-player-controls.-
|
|
219
|
+
.magic-player-controls:not(.-standalone).-playing.-idle
|
|
220
|
+
.magic-player-controls__bar,
|
|
221
|
+
.magic-player-controls:not(.-standalone).-playing.-not-hover
|
|
222
|
+
.magic-player-controls__bar,
|
|
223
|
+
.magic-player-controls:not(.-standalone).-untouched
|
|
224
|
+
.magic-player-controls__bar {
|
|
257
225
|
opacity: 0;
|
|
258
|
-
transform:
|
|
226
|
+
transform: translateY(25%);
|
|
259
227
|
}
|
|
260
228
|
|
|
261
|
-
.magic-player-controls.-
|
|
262
|
-
|
|
263
|
-
|
|
229
|
+
.magic-player-controls.-standalone {
|
|
230
|
+
position: relative;
|
|
231
|
+
inset: unset;
|
|
232
|
+
--magic-player-controls-width: 100%;
|
|
233
|
+
--magic-player-controls-bottom: 0;
|
|
234
|
+
--magic-player-controls-left: 0;
|
|
235
|
+
--magic-player-controls-padding: 0;
|
|
236
|
+
--magic-player-controls-background-color: unset;
|
|
237
|
+
--magic-player-controls-border-radius: unset;
|
|
238
|
+
--magic-player-controls-background-color: transparent;
|
|
239
|
+
--magic-player-controls-backdrop-filter: none;
|
|
240
|
+
--magic-player-controls-transition-duration: unset;
|
|
241
|
+
--magic-player-controls-transition-timing-function: unset;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.magic-player-controls.-standalone .magic-player-controls__bar {
|
|
245
|
+
position: relative;
|
|
264
246
|
}
|
|
265
247
|
</style>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
seekedTime: import("vue").Ref<number>;
|
|
6
|
-
seekedPercentage: import("vue").Ref<number>;
|
|
7
|
-
scrubbedPercentage: import("vue").Ref<number>;
|
|
8
|
-
bufferedPercentage: import("vue").ComputedRef<any>;
|
|
9
|
-
thumbPercentage: import("vue").Ref<number>;
|
|
10
|
-
popoverOffsetX: import("vue").Ref<number>;
|
|
11
|
-
onMouseEnter: () => void;
|
|
12
|
-
onMouseLeave: () => void;
|
|
13
|
-
onPointerDown: (e: MouseEvent | TouchEvent) => void;
|
|
14
|
-
onPointerUp: () => void;
|
|
15
|
-
onPointerMove: (e: MouseEvent | TouchEvent) => void;
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
2
|
+
id: {
|
|
3
|
+
type: import("vue").PropType<string>;
|
|
4
|
+
required: true;
|
|
16
5
|
};
|
|
17
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
6
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
+
id: {
|
|
8
|
+
type: import("vue").PropType<string>;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
}>>, {}, {}>, {
|
|
18
12
|
seekPopover?(_: {}): any;
|
|
13
|
+
playIcon?(_: {}): any;
|
|
14
|
+
pauseIcon?(_: {}): any;
|
|
15
|
+
volumeOffIcon?(_: {}): any;
|
|
16
|
+
volumeOnIcon?(_: {}): any;
|
|
17
|
+
fullscreenExitIcon?(_: {}): any;
|
|
18
|
+
fullscreenEnterIcon?(_: {}): any;
|
|
19
19
|
}>;
|
|
20
20
|
export default _default;
|
|
21
21
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
@@ -14,16 +14,12 @@
|
|
|
14
14
|
</div>
|
|
15
15
|
</template>
|
|
16
16
|
<script setup lang="ts">
|
|
17
|
-
import { shallowRef, onMounted, watch, computed } from 'vue'
|
|
17
|
+
import { shallowRef, onMounted, watch, computed, toRefs, type Ref } from 'vue'
|
|
18
18
|
import { useDevicePixelRatio } from '@vueuse/core'
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
const { controlsApi } = useInjectControls()
|
|
22
|
-
const { seekedTime } = controlsApi
|
|
23
|
-
|
|
24
|
-
import type { Ref } from 'vue'
|
|
19
|
+
import { usePlayerApi } from '../composables/usePlayerApi'
|
|
25
20
|
|
|
26
21
|
type Props = {
|
|
22
|
+
id: string
|
|
27
23
|
playbackId: string
|
|
28
24
|
}
|
|
29
25
|
|
|
@@ -40,13 +36,17 @@ type MuxStoryboard = {
|
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
const props = defineProps<Props>()
|
|
39
|
+
|
|
40
|
+
const { instance } = usePlayerApi(props.id)
|
|
41
|
+
|
|
42
|
+
const { seekedTime } = toRefs(instance.value.controlsApi)
|
|
43
|
+
const { pixelRatio } = useDevicePixelRatio()
|
|
44
|
+
|
|
43
45
|
const canvas = shallowRef() as Ref<HTMLCanvasElement>
|
|
44
|
-
let context: CanvasRenderingContext2D | undefined = undefined
|
|
45
46
|
const storyboard = shallowRef<MuxStoryboard | undefined>()
|
|
47
|
+
let context: CanvasRenderingContext2D | undefined = undefined
|
|
46
48
|
let image: HTMLImageElement | undefined = undefined
|
|
47
49
|
|
|
48
|
-
const { pixelRatio } = useDevicePixelRatio()
|
|
49
|
-
|
|
50
50
|
const thumbWidth = computed(() => {
|
|
51
51
|
if (!storyboard.value) return 0
|
|
52
52
|
return storyboard.value.tile_width / pixelRatio.value
|
|
@@ -112,7 +112,7 @@ function drawFrame(time: number) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
onMounted(init)
|
|
115
|
-
watch(() => seekedTime
|
|
115
|
+
watch(() => seekedTime?.value, drawFrame)
|
|
116
116
|
</script>
|
|
117
117
|
|
|
118
118
|
<style lang="css">
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
id: {
|
|
3
|
+
type: import("vue").PropType<string>;
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
2
6
|
playbackId: {
|
|
3
7
|
type: import("vue").PropType<string>;
|
|
4
8
|
required: true;
|
|
5
9
|
};
|
|
6
10
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
11
|
+
id: {
|
|
12
|
+
type: import("vue").PropType<string>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
7
15
|
playbackId: {
|
|
8
16
|
type: import("vue").PropType<string>;
|
|
9
17
|
required: true;
|