@maas/vue-equipment 0.11.6 → 0.12.1
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 +40 -21
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue.d.ts +19 -28
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue +70 -90
- 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 +96 -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} +22 -19
- 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 +20 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerStore.mjs +42 -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 +4 -18
- 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,10 +1,17 @@
|
|
|
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"
|
|
6
12
|
preload="auto"
|
|
7
13
|
playsinline
|
|
14
|
+
disablePictureInPicture
|
|
8
15
|
/>
|
|
9
16
|
<div v-show="!loaded || !touched" class="magic-player-poster">
|
|
10
17
|
<slot name="poster" />
|
|
@@ -16,15 +23,17 @@
|
|
|
16
23
|
<script setup lang="ts">
|
|
17
24
|
import { ref, computed } from 'vue'
|
|
18
25
|
import { useIntersectionObserver } from '@vueuse/core'
|
|
19
|
-
import {
|
|
26
|
+
import { usePlayerApi } from '../composables/usePlayerApi'
|
|
20
27
|
|
|
21
28
|
import type { SourceType } from './../types'
|
|
22
29
|
|
|
23
30
|
export type MagicPlayerProps = {
|
|
31
|
+
id: string
|
|
24
32
|
srcType?: SourceType
|
|
25
33
|
src: string
|
|
26
34
|
ratio?: string
|
|
27
35
|
fill?: boolean
|
|
36
|
+
autoplay?: boolean
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
const props = withDefaults(defineProps<MagicPlayerProps>(), {
|
|
@@ -32,26 +41,39 @@ const props = withDefaults(defineProps<MagicPlayerProps>(), {
|
|
|
32
41
|
src: '',
|
|
33
42
|
ratio: '16:9',
|
|
34
43
|
fill: false,
|
|
44
|
+
autoplay: false,
|
|
35
45
|
})
|
|
36
46
|
|
|
37
47
|
const playerRef = ref<HTMLDivElement | undefined>(undefined)
|
|
38
48
|
const videoRef = ref<HTMLVideoElement | undefined>(undefined)
|
|
39
49
|
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
// Initialize instance
|
|
51
|
+
const { instance } = usePlayerApi({
|
|
52
|
+
id: props.id,
|
|
42
53
|
videoRef: videoRef,
|
|
43
|
-
|
|
54
|
+
playerRef: playerRef,
|
|
44
55
|
srcType: props.srcType,
|
|
56
|
+
src: props.src,
|
|
45
57
|
})
|
|
46
|
-
const { playing } = mediaApi
|
|
47
|
-
const { touched, pause } = playerApi
|
|
48
|
-
const { loaded } = runtimeProvider
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
const { playing } = instance.value?.mediaApi
|
|
60
|
+
const { touched } = instance.value?.playerApi
|
|
61
|
+
const { onMouseenter, onMouseleave } = instance.value?.playerApi
|
|
62
|
+
const { loaded } = instance.value?.runtimeProvider
|
|
63
|
+
|
|
64
|
+
useIntersectionObserver(
|
|
65
|
+
playerRef,
|
|
66
|
+
([{ isIntersecting }]) => {
|
|
67
|
+
if (!isIntersecting && playing.value) {
|
|
68
|
+
instance.value.playerApi.pause()
|
|
69
|
+
} else if (isIntersecting && !playing.value && props.autoplay) {
|
|
70
|
+
instance.value.playerApi.play()
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
immediate: true,
|
|
75
|
+
},
|
|
76
|
+
)
|
|
55
77
|
|
|
56
78
|
const computedRatio = computed(() => {
|
|
57
79
|
if (props.ratio) {
|
|
@@ -70,21 +92,18 @@ const computedStyle = computed(() => {
|
|
|
70
92
|
: undefined,
|
|
71
93
|
}
|
|
72
94
|
})
|
|
73
|
-
|
|
74
|
-
defineExpose({
|
|
75
|
-
playerApi,
|
|
76
|
-
mediaApi,
|
|
77
|
-
runtimeProvider,
|
|
78
|
-
})
|
|
79
95
|
</script>
|
|
80
96
|
|
|
81
97
|
<style lang="css">
|
|
98
|
+
:root {
|
|
99
|
+
--magic-player-aspect-ratio: 16 / 9;
|
|
100
|
+
}
|
|
101
|
+
|
|
82
102
|
.magic-player {
|
|
83
|
-
--aspect-ratio: 16 / 9;
|
|
84
103
|
position: relative;
|
|
85
104
|
width: 100%;
|
|
86
105
|
overflow: hidden;
|
|
87
|
-
aspect-ratio: var(--aspect-ratio);
|
|
106
|
+
aspect-ratio: var(--magic-player-aspect-ratio);
|
|
88
107
|
}
|
|
89
108
|
|
|
90
109
|
.magic-player-video {
|
|
@@ -1,15 +1,21 @@
|
|
|
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;
|
|
6
7
|
fill?: boolean;
|
|
8
|
+
autoplay?: boolean;
|
|
7
9
|
};
|
|
8
10
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
9
11
|
fill: {
|
|
10
12
|
type: import("vue").PropType<boolean>;
|
|
11
13
|
default: boolean;
|
|
12
14
|
};
|
|
15
|
+
id: {
|
|
16
|
+
type: import("vue").PropType<string>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
13
19
|
srcType: {
|
|
14
20
|
type: import("vue").PropType<SourceType>;
|
|
15
21
|
default: string;
|
|
@@ -23,39 +29,19 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
23
29
|
type: import("vue").PropType<string>;
|
|
24
30
|
default: string;
|
|
25
31
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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>;
|
|
32
|
+
autoplay: {
|
|
33
|
+
type: import("vue").PropType<boolean>;
|
|
34
|
+
default: boolean;
|
|
52
35
|
};
|
|
53
|
-
|
|
54
|
-
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
36
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
55
37
|
fill: {
|
|
56
38
|
type: import("vue").PropType<boolean>;
|
|
57
39
|
default: boolean;
|
|
58
40
|
};
|
|
41
|
+
id: {
|
|
42
|
+
type: import("vue").PropType<string>;
|
|
43
|
+
required: true;
|
|
44
|
+
};
|
|
59
45
|
srcType: {
|
|
60
46
|
type: import("vue").PropType<SourceType>;
|
|
61
47
|
default: string;
|
|
@@ -69,11 +55,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
69
55
|
type: import("vue").PropType<string>;
|
|
70
56
|
default: string;
|
|
71
57
|
};
|
|
58
|
+
autoplay: {
|
|
59
|
+
type: import("vue").PropType<boolean>;
|
|
60
|
+
default: boolean;
|
|
61
|
+
};
|
|
72
62
|
}>>, {
|
|
73
63
|
fill: boolean;
|
|
74
64
|
srcType: SourceType;
|
|
75
65
|
src: string;
|
|
76
66
|
ratio: string;
|
|
67
|
+
autoplay: boolean;
|
|
77
68
|
}, {}>, {
|
|
78
69
|
poster?(_: {}): any;
|
|
79
70
|
default?(_: {}): any;
|
|
@@ -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>
|
|
@@ -85,59 +80,52 @@ 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
|
-
isFullscreen,
|
|
107
|
-
play,
|
|
108
|
-
pause,
|
|
109
|
-
togglePlay,
|
|
110
|
-
mute,
|
|
111
|
-
unmute,
|
|
112
|
-
enterFullscreen,
|
|
113
|
-
exitFullscreen,
|
|
114
|
-
} = playerApi
|
|
102
|
+
const { playing, waiting, muted } = instance.value.mediaApi
|
|
103
|
+
const { touched, mouseEntered, isFullscreen } = instance.value.playerApi
|
|
104
|
+
const { popoverOffsetX, seekedTime } = instance.value.controlsApi
|
|
115
105
|
|
|
116
|
-
const {
|
|
106
|
+
const { play, pause, mute, unmute, enterFullscreen, exitFullscreen } =
|
|
107
|
+
instance.value.playerApi
|
|
117
108
|
|
|
118
109
|
const { idle } = useIdle(3000)
|
|
119
|
-
const isMouseEnter = ref(false)
|
|
120
|
-
|
|
121
|
-
defineExpose({
|
|
122
|
-
controlsApi,
|
|
123
|
-
})
|
|
124
110
|
</script>
|
|
125
111
|
|
|
126
112
|
<style lang="css">
|
|
127
113
|
:root {
|
|
128
114
|
--magic-player-controls-height: 3rem;
|
|
129
|
-
--magic-player-controls-bottom: 1.5rem;
|
|
130
115
|
--magic-player-controls-padding: 0.75rem;
|
|
116
|
+
--magic-player-controls-bottom: 1.5rem;
|
|
117
|
+
--magic-player-controls-left: 1.5rem;
|
|
118
|
+
--magic-player-controls-width: calc(
|
|
119
|
+
100% - (var(--magic-player-controls-left) * 2)
|
|
120
|
+
);
|
|
131
121
|
--magic-player-controls-gap: 1rem;
|
|
132
122
|
--magic-player-controls-border-radius: 50rem;
|
|
133
123
|
--magic-player-controls-background-color: rgba(32, 32, 32, 0.8);
|
|
134
124
|
--magic-player-controls-backdrop-filter: blur(80px);
|
|
135
125
|
--magic-player-controls-color: rgba(255, 255, 255, 1);
|
|
136
126
|
--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
127
|
--magic-player-controls-transition-duration: 300ms;
|
|
140
|
-
--magic-player-controls-transition-timing-function: ease
|
|
128
|
+
--magic-player-controls-transition-timing-function: ease;
|
|
141
129
|
}
|
|
142
130
|
|
|
143
131
|
@media (max-width: 640px) {
|
|
@@ -151,41 +139,15 @@ defineExpose({
|
|
|
151
139
|
.magic-player-controls {
|
|
152
140
|
position: absolute;
|
|
153
141
|
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;
|
|
142
|
+
width: 100%;
|
|
143
|
+
pointer-events: none;
|
|
181
144
|
}
|
|
182
145
|
|
|
183
146
|
.magic-player-controls__bar {
|
|
184
147
|
position: absolute;
|
|
185
|
-
width:
|
|
148
|
+
width: var(--magic-player-controls-width);
|
|
186
149
|
bottom: var(--magic-player-controls-bottom);
|
|
187
|
-
left:
|
|
188
|
-
transform: translateX(-50%);
|
|
150
|
+
left: var(--magic-player-controls-left);
|
|
189
151
|
margin: 0 auto;
|
|
190
152
|
display: flex;
|
|
191
153
|
flex-direction: column;
|
|
@@ -196,6 +158,7 @@ defineExpose({
|
|
|
196
158
|
--magic-player-controls-transition-timing-function
|
|
197
159
|
);
|
|
198
160
|
transition-property: opacity, transform;
|
|
161
|
+
pointer-events: auto;
|
|
199
162
|
}
|
|
200
163
|
|
|
201
164
|
.magic-player-controls__bar--inner {
|
|
@@ -251,15 +214,32 @@ defineExpose({
|
|
|
251
214
|
width: 100%;
|
|
252
215
|
}
|
|
253
216
|
|
|
254
|
-
.magic-player-controls.-playing.-idle
|
|
255
|
-
.magic-player-
|
|
256
|
-
.magic-player-controls.-
|
|
217
|
+
.magic-player-controls:not(.-standalone).-playing.-idle
|
|
218
|
+
.magic-player-controls__bar,
|
|
219
|
+
.magic-player-controls:not(.-standalone).-playing.-not-hover
|
|
220
|
+
.magic-player-controls__bar,
|
|
221
|
+
.magic-player-controls:not(.-standalone).-untouched
|
|
222
|
+
.magic-player-controls__bar {
|
|
257
223
|
opacity: 0;
|
|
258
|
-
transform:
|
|
224
|
+
transform: translateY(25%);
|
|
259
225
|
}
|
|
260
226
|
|
|
261
|
-
.magic-player-controls.-
|
|
262
|
-
|
|
263
|
-
|
|
227
|
+
.magic-player-controls.-standalone {
|
|
228
|
+
position: relative;
|
|
229
|
+
inset: unset;
|
|
230
|
+
--magic-player-controls-width: 100%;
|
|
231
|
+
--magic-player-controls-bottom: 0;
|
|
232
|
+
--magic-player-controls-left: 0;
|
|
233
|
+
--magic-player-controls-padding: 0;
|
|
234
|
+
--magic-player-controls-background-color: unset;
|
|
235
|
+
--magic-player-controls-border-radius: unset;
|
|
236
|
+
--magic-player-controls-background-color: transparent;
|
|
237
|
+
--magic-player-controls-backdrop-filter: none;
|
|
238
|
+
--magic-player-controls-transition-duration: unset;
|
|
239
|
+
--magic-player-controls-transition-timing-function: unset;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.magic-player-controls.-standalone .magic-player-controls__bar {
|
|
243
|
+
position: relative;
|
|
264
244
|
}
|
|
265
245
|
</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 & {
|