@maas/vue-equipment 1.0.0-beta.43 → 1.0.0-beta.44
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/composables/useScrollLockPadding/index.js +1 -0
- package/dist/composables/useScrollLockPadding/index.js.map +1 -1
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +2 -5
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.d.ts +2 -3
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.mjs +38 -11
- package/dist/plugins/MagicAccordion/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.d.vue.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +2 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +1 -0
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.d.ts +2 -3
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.mjs +36 -11
- package/dist/plugins/MagicCommand/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.d.ts +2 -3
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.mjs +35 -12
- package/dist/plugins/MagicCookie/src/composables/useMagicCookie.mjs +6 -1
- package/dist/plugins/MagicCookie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +28 -11
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +11 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +41 -11
- package/dist/plugins/MagicDraggable/src/composables/useMagicDraggable.mjs +2 -1
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.d.vue.ts +2 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +11 -3
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.d.ts +2 -0
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +184 -29
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +2 -3
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +35 -10
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +2 -1
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.mjs +10 -5
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +2 -5
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.d.ts +2 -3
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.mjs +36 -11
- package/dist/plugins/MagicMarquee/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.d.vue.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +2 -6
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCursor.mjs +13 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.d.ts +2 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.mjs +32 -12
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +1 -1
- package/dist/plugins/MagicMenu/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalState.d.ts +6 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalState.mjs +58 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.d.ts +1 -5
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.mjs +1 -15
- package/dist/plugins/MagicModal/src/composables/useMagicModal.mjs +7 -6
- package/dist/plugins/MagicModal/src/types/index.d.ts +5 -0
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +14 -2
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +12 -6
- package/dist/plugins/MagicPie/src/composables/private/usePieState.d.ts +1 -1
- package/dist/plugins/MagicPie/src/composables/private/usePieState.mjs +33 -12
- package/dist/plugins/MagicPie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +9 -6
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +4 -8
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +8 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +2 -11
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +10 -6
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +4 -8
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.mjs +20 -9
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerEmitter.mjs +124 -75
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +100 -32
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +33 -13
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.d.ts +2 -3
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +35 -10
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +0 -2
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +13 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +9 -5
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetection.mjs +2 -1
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +2 -11
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +1 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +13 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastState.d.ts +2 -3
- package/dist/plugins/MagicToast/src/composables/private/useToastState.mjs +35 -12
- package/dist/plugins/MagicToast/src/types/index.d.ts +1 -0
- package/dist/utils/index.d.ts +8 -1
- package/dist/utils/index.js +56497 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/plugins/MagicError/src/MagicError.d.ts +0 -0
- package/dist/plugins/MagicError/src/MagicError.mjs +0 -0
|
@@ -79,7 +79,11 @@ function drawFrame(time) {
|
|
|
79
79
|
let closestIndex = -1;
|
|
80
80
|
let minDifference = Infinity;
|
|
81
81
|
for (let i = 0; i < tiles.length; i++) {
|
|
82
|
-
const
|
|
82
|
+
const tile2 = tiles[i];
|
|
83
|
+
if (!tile2) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const { start } = tile2;
|
|
83
87
|
const difference = Math.abs(start - time);
|
|
84
88
|
if (difference < minDifference) {
|
|
85
89
|
minDifference = difference;
|
|
@@ -87,6 +91,9 @@ function drawFrame(time) {
|
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
const tile = tiles[closestIndex];
|
|
94
|
+
if (!tile) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
90
97
|
context.drawImage(
|
|
91
98
|
image,
|
|
92
99
|
tile.x,
|
|
@@ -21,13 +21,7 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script setup>
|
|
24
|
-
import {
|
|
25
|
-
toRefs,
|
|
26
|
-
provide,
|
|
27
|
-
onMounted,
|
|
28
|
-
onUnmounted,
|
|
29
|
-
useTemplateRef
|
|
30
|
-
} from "vue";
|
|
24
|
+
import { toRefs, provide, onMounted, useTemplateRef } from "vue";
|
|
31
25
|
import defu from "defu";
|
|
32
26
|
import { usePlayerState } from "../composables/private/usePlayerState";
|
|
33
27
|
import {
|
|
@@ -43,7 +37,7 @@ const { id, options } = defineProps({
|
|
|
43
37
|
options: { type: Object, required: false }
|
|
44
38
|
});
|
|
45
39
|
const mappedOptions = defu(options, defaultOptions);
|
|
46
|
-
const { initializeState
|
|
40
|
+
const { initializeState } = usePlayerState(id);
|
|
47
41
|
const state = initializeState();
|
|
48
42
|
const {
|
|
49
43
|
playing,
|
|
@@ -61,9 +55,6 @@ const { initializeEmitter } = usePlayerEmitter({ id });
|
|
|
61
55
|
onMounted(() => {
|
|
62
56
|
initializeEmitter();
|
|
63
57
|
});
|
|
64
|
-
onUnmounted(() => {
|
|
65
|
-
deleteState();
|
|
66
|
-
});
|
|
67
58
|
provide(MagicPlayerInstanceId, id);
|
|
68
59
|
provide(MagicPlayerOptionsKey, mappedOptions);
|
|
69
60
|
provide(MagicPlayerRef, playerRef);
|
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
watch,
|
|
18
18
|
onMounted,
|
|
19
19
|
inject,
|
|
20
|
-
onBeforeUnmount,
|
|
21
20
|
shallowRef,
|
|
22
|
-
computed
|
|
21
|
+
computed,
|
|
22
|
+
onBeforeUnmount
|
|
23
23
|
} from "vue";
|
|
24
24
|
import {
|
|
25
25
|
useElementVisibility,
|
|
@@ -46,6 +46,8 @@ const magicError = useMagicError({
|
|
|
46
46
|
const injectedInstanceId = inject(MagicPlayerInstanceId, void 0);
|
|
47
47
|
const injectedOptions = inject(MagicPlayerOptionsKey, void 0);
|
|
48
48
|
const injectedPlayerRef = inject(MagicPlayerRef, void 0);
|
|
49
|
+
let cancelFocus = void 0;
|
|
50
|
+
let cancelBlur = void 0;
|
|
49
51
|
magicError.assert(injectedInstanceId, {
|
|
50
52
|
message: "MagicPlayerVideo must be used within a MagicPlayerProvider",
|
|
51
53
|
errorCode: "missing_instance_id"
|
|
@@ -55,7 +57,7 @@ magicError.assert(injectedOptions, {
|
|
|
55
57
|
errorCode: "missing_options"
|
|
56
58
|
});
|
|
57
59
|
const elRef = useTemplateRef("el");
|
|
58
|
-
const { initialize
|
|
60
|
+
const { initialize } = usePlayerRuntime({
|
|
59
61
|
id: injectedInstanceId,
|
|
60
62
|
mediaRef: elRef,
|
|
61
63
|
src: injectedOptions.src,
|
|
@@ -94,8 +96,8 @@ function onWindowBlur() {
|
|
|
94
96
|
pause();
|
|
95
97
|
}
|
|
96
98
|
if (manageWindow.value) {
|
|
97
|
-
useEventListener(defaultWindow, "focus", onWindowFocus);
|
|
98
|
-
useEventListener(defaultWindow, "blur", onWindowBlur);
|
|
99
|
+
cancelFocus = useEventListener(defaultWindow, "focus", onWindowFocus);
|
|
100
|
+
cancelBlur = useEventListener(defaultWindow, "blur", onWindowBlur);
|
|
99
101
|
}
|
|
100
102
|
if (manageViewport.value) {
|
|
101
103
|
watch(isVisible, (value) => {
|
|
@@ -139,7 +141,9 @@ onMounted(async () => {
|
|
|
139
141
|
}
|
|
140
142
|
});
|
|
141
143
|
onBeforeUnmount(() => {
|
|
142
|
-
|
|
144
|
+
state.fullscreenTarget = null;
|
|
145
|
+
cancelFocus?.();
|
|
146
|
+
cancelBlur?.();
|
|
143
147
|
});
|
|
144
148
|
</script>
|
|
145
149
|
|
|
@@ -158,13 +158,7 @@ const {
|
|
|
158
158
|
dragging
|
|
159
159
|
} = toRefs(state);
|
|
160
160
|
const { play, pause, mute, unmute, enterFullscreen, exitFullscreen } = usePlayerVideoApi({ id: mappedInstanceId.value });
|
|
161
|
-
const {
|
|
162
|
-
initialize,
|
|
163
|
-
destroy,
|
|
164
|
-
onMouseenter,
|
|
165
|
-
onMouseleave,
|
|
166
|
-
onMouseleaveTimeline
|
|
167
|
-
} = usePlayerControlsApi({
|
|
161
|
+
const { initialize, onMouseenter, onMouseleave, onMouseleaveTimeline } = usePlayerControlsApi({
|
|
168
162
|
id: mappedInstanceId.value,
|
|
169
163
|
barRef,
|
|
170
164
|
trackRef,
|
|
@@ -188,7 +182,9 @@ const visible = computed(() => {
|
|
|
188
182
|
});
|
|
189
183
|
initialize();
|
|
190
184
|
onBeforeUnmount(() => {
|
|
191
|
-
|
|
185
|
+
state.controlsBarRect = void 0;
|
|
186
|
+
state.controlsTrackRect = void 0;
|
|
187
|
+
state.controlsPopoverRect = void 0;
|
|
192
188
|
});
|
|
193
189
|
provide(MagicPlayerInstanceId, mappedInstanceId.value);
|
|
194
190
|
provide(MagicPlayerTrackRef, trackRef);
|
|
@@ -7,7 +7,6 @@ export type UsePlayerControlsApiArgs = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare function usePlayerControlsApi(args: UsePlayerControlsApiArgs): {
|
|
9
9
|
initialize: () => void;
|
|
10
|
-
destroy: () => void;
|
|
11
10
|
bufferedPercentage: import("vue").ComputedRef<number>;
|
|
12
11
|
onMouseenter: () => void;
|
|
13
12
|
onMouseleave: () => void;
|
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
shallowRef,
|
|
4
4
|
computed,
|
|
5
5
|
watch,
|
|
6
|
-
toValue
|
|
6
|
+
toValue,
|
|
7
|
+
onScopeDispose,
|
|
8
|
+
markRaw
|
|
7
9
|
} from "vue";
|
|
8
10
|
import {
|
|
9
11
|
useResizeObserver,
|
|
@@ -49,7 +51,7 @@ export function usePlayerControlsApi(args) {
|
|
|
49
51
|
if (!buffered.value) {
|
|
50
52
|
return 0;
|
|
51
53
|
}
|
|
52
|
-
const endBuffer = buffered.value?.length > 0 ? buffered.value[0][1] : 0;
|
|
54
|
+
const endBuffer = buffered.value?.length > 0 && buffered.value[0] ? buffered.value[0][1] : 0;
|
|
53
55
|
const percentage = endBuffer / duration.value * 100;
|
|
54
56
|
return clampValue(percentage, 0, thumbPercentage.value);
|
|
55
57
|
});
|
|
@@ -69,15 +71,19 @@ export function usePlayerControlsApi(args) {
|
|
|
69
71
|
if (!toValue(trackRef)) {
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
|
-
controlsTrackRect.value =
|
|
74
|
+
controlsTrackRect.value = markRaw(
|
|
75
|
+
toValue(trackRef).getBoundingClientRect()
|
|
76
|
+
);
|
|
73
77
|
thumbPercentage.value = 100 - controlsTrackRect.value.height / controlsTrackRect.value.width * 100;
|
|
74
78
|
}
|
|
75
79
|
function getPopoverSizes() {
|
|
76
80
|
if (!toValue(barRef) || !toValue(popoverRef)) {
|
|
77
81
|
return;
|
|
78
82
|
}
|
|
79
|
-
controlsBarRect.value = toValue(barRef).getBoundingClientRect();
|
|
80
|
-
controlsPopoverRect.value =
|
|
83
|
+
controlsBarRect.value = markRaw(toValue(barRef).getBoundingClientRect());
|
|
84
|
+
controlsPopoverRect.value = markRaw(
|
|
85
|
+
toValue(popoverRef).getBoundingClientRect()
|
|
86
|
+
);
|
|
81
87
|
}
|
|
82
88
|
function getSizes() {
|
|
83
89
|
getTimelineTrackSize();
|
|
@@ -174,9 +180,9 @@ export function usePlayerControlsApi(args) {
|
|
|
174
180
|
let windowResizeCleanup = null;
|
|
175
181
|
function initialize() {
|
|
176
182
|
hasControls.value = true;
|
|
177
|
-
watchTrack = watch(() => trackRef, getTimelineTrackSize);
|
|
178
|
-
watchPopover = watch(() => popoverRef, getPopoverSizes);
|
|
179
|
-
watchBar = watch(() => barRef, getPopoverSizes);
|
|
183
|
+
watchTrack = watch(() => trackRef?.value, getTimelineTrackSize);
|
|
184
|
+
watchPopover = watch(() => popoverRef?.value, getPopoverSizes);
|
|
185
|
+
watchBar = watch(() => barRef?.value, getPopoverSizes);
|
|
180
186
|
watchCurrentTime = watch(currentTime, (value) => {
|
|
181
187
|
const percentage = value / duration?.value * 100;
|
|
182
188
|
scrubbedPercentage.value = mapValue(
|
|
@@ -210,10 +216,15 @@ export function usePlayerControlsApi(args) {
|
|
|
210
216
|
resizeObserverPopover?.stop();
|
|
211
217
|
resizeObserverBar?.stop();
|
|
212
218
|
windowResizeCleanup?.();
|
|
219
|
+
cancelPointermove?.();
|
|
220
|
+
cancelPointerup?.();
|
|
221
|
+
cancelTouchend?.();
|
|
213
222
|
}
|
|
223
|
+
onScopeDispose(() => {
|
|
224
|
+
destroy();
|
|
225
|
+
});
|
|
214
226
|
return {
|
|
215
227
|
initialize,
|
|
216
|
-
destroy,
|
|
217
228
|
bufferedPercentage,
|
|
218
229
|
onMouseenter,
|
|
219
230
|
onMouseleave,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
toRefs,
|
|
3
|
+
watch,
|
|
4
|
+
toValue,
|
|
5
|
+
onScopeDispose
|
|
6
|
+
} from "vue";
|
|
2
7
|
import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
|
|
3
8
|
import { usePlayerState } from "./usePlayerState.mjs";
|
|
4
9
|
export function usePlayerEmitter(args) {
|
|
5
10
|
const { id } = args;
|
|
11
|
+
let scopeInitialized = false;
|
|
6
12
|
const { initializeState } = usePlayerState(toValue(id));
|
|
7
13
|
const state = initializeState();
|
|
8
14
|
const {
|
|
@@ -20,83 +26,126 @@ export function usePlayerEmitter(args) {
|
|
|
20
26
|
volume,
|
|
21
27
|
waiting
|
|
22
28
|
} = toRefs(state);
|
|
29
|
+
let stops = [];
|
|
23
30
|
const emitter = useMagicEmitter();
|
|
31
|
+
function destroyEmitter() {
|
|
32
|
+
for (const stop of stops) {
|
|
33
|
+
try {
|
|
34
|
+
stop();
|
|
35
|
+
} catch {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
stops = [];
|
|
39
|
+
}
|
|
24
40
|
function initializeEmitter() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
41
|
+
if (scopeInitialized) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
scopeInitialized = true;
|
|
45
|
+
stops.push(
|
|
46
|
+
watch(dragging, (newDragging) => {
|
|
47
|
+
if (newDragging) {
|
|
48
|
+
emitter.emit("onDragStart", toValue(id));
|
|
49
|
+
}
|
|
50
|
+
if (!newDragging) {
|
|
51
|
+
emitter.emit("onDragEnd", toValue(id));
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
stops.push(
|
|
56
|
+
watch(ended, (newEnded) => {
|
|
57
|
+
if (newEnded) {
|
|
58
|
+
emitter.emit("onEnd", toValue(id));
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
stops.push(
|
|
63
|
+
watch(fullscreen, (newFullscreen) => {
|
|
64
|
+
if (newFullscreen) {
|
|
65
|
+
emitter.emit("onFullscreenEnter", toValue(id));
|
|
66
|
+
}
|
|
67
|
+
if (!newFullscreen) {
|
|
68
|
+
emitter.emit("onFullscreenLeave", toValue(id));
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
stops.push(
|
|
73
|
+
watch(loaded, (newLoaded) => {
|
|
74
|
+
if (newLoaded) {
|
|
75
|
+
emitter.emit("onLoad", toValue(id));
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
stops.push(
|
|
80
|
+
watch(muted, (newMuted) => {
|
|
81
|
+
if (newMuted) {
|
|
82
|
+
emitter.emit("onMute", toValue(id));
|
|
83
|
+
}
|
|
84
|
+
if (!newMuted) {
|
|
85
|
+
emitter.emit("onUnmute", toValue(id));
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
stops.push(
|
|
90
|
+
watch(paused, (newPaused) => {
|
|
91
|
+
if (newPaused) {
|
|
92
|
+
emitter.emit("onPause", toValue(id));
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
stops.push(
|
|
97
|
+
watch(playing, (newPlaying) => {
|
|
98
|
+
if (newPlaying) {
|
|
99
|
+
emitter.emit("onPlay", toValue(id));
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
stops.push(
|
|
104
|
+
watch(rate, (newRate) => {
|
|
105
|
+
if (newRate) {
|
|
106
|
+
emitter.emit("onRateChange", toValue(id));
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
stops.push(
|
|
111
|
+
watch(started, (newStarted) => {
|
|
112
|
+
if (newStarted) {
|
|
113
|
+
emitter.emit("onStart", toValue(id));
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
stops.push(
|
|
118
|
+
watch(stalled, (newStalled) => {
|
|
119
|
+
if (newStalled) {
|
|
120
|
+
emitter.emit("onStall", toValue(id));
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
stops.push(
|
|
125
|
+
watch(touched, (newTouched) => {
|
|
126
|
+
if (newTouched) {
|
|
127
|
+
emitter.emit("onTouch", toValue(id));
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
stops.push(
|
|
132
|
+
watch(volume, (newVolume) => {
|
|
133
|
+
if (newVolume) {
|
|
134
|
+
emitter.emit("onVolumeChange", toValue(id));
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
stops.push(
|
|
139
|
+
watch(waiting, (newWaiting) => {
|
|
140
|
+
if (newWaiting) {
|
|
141
|
+
emitter.emit("onWait", toValue(id));
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
);
|
|
99
145
|
}
|
|
146
|
+
onScopeDispose(() => {
|
|
147
|
+
destroyEmitter();
|
|
148
|
+
});
|
|
100
149
|
return {
|
|
101
150
|
initializeEmitter
|
|
102
151
|
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
toRefs,
|
|
3
|
+
watch,
|
|
4
|
+
unref,
|
|
5
|
+
toValue,
|
|
6
|
+
onScopeDispose
|
|
7
|
+
} from "vue";
|
|
2
8
|
import { useEventListener, watchIgnorable } from "@vueuse/core";
|
|
3
9
|
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
4
10
|
import { usePlayerState } from "./usePlayerState.mjs";
|
|
@@ -137,67 +143,129 @@ export function usePlayerMediaApi(args) {
|
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
145
|
);
|
|
140
|
-
|
|
146
|
+
function timeupdateCallback() {
|
|
141
147
|
ignoreCurrentTimeUpdates(
|
|
142
148
|
() => currentTime.value = toValue(mediaRef).currentTime
|
|
143
149
|
);
|
|
144
|
-
}
|
|
145
|
-
|
|
150
|
+
}
|
|
151
|
+
function durationChangeCallback() {
|
|
146
152
|
duration.value = toValue(mediaRef).duration;
|
|
147
|
-
}
|
|
148
|
-
|
|
153
|
+
}
|
|
154
|
+
function progressCallback() {
|
|
149
155
|
buffered.value = timeRangeToArray(toValue(mediaRef).buffered);
|
|
150
|
-
}
|
|
151
|
-
|
|
156
|
+
}
|
|
157
|
+
function seekingCallback() {
|
|
152
158
|
seeking.value = true;
|
|
153
|
-
}
|
|
154
|
-
|
|
159
|
+
}
|
|
160
|
+
function seekedCallback() {
|
|
155
161
|
seeking.value = false;
|
|
156
|
-
}
|
|
157
|
-
|
|
162
|
+
}
|
|
163
|
+
function waitingLoadstartCallback() {
|
|
158
164
|
waiting.value = true;
|
|
159
165
|
ignorePlayingUpdates(() => playing.value = false);
|
|
160
|
-
}
|
|
161
|
-
|
|
166
|
+
}
|
|
167
|
+
function loadeddataCallback() {
|
|
162
168
|
waiting.value = false;
|
|
163
|
-
}
|
|
164
|
-
|
|
169
|
+
}
|
|
170
|
+
function playingCallback() {
|
|
165
171
|
started.value = true;
|
|
166
172
|
waiting.value = false;
|
|
167
173
|
ended.value = false;
|
|
168
174
|
ignorePlayingUpdates(() => playing.value = true);
|
|
169
|
-
}
|
|
170
|
-
|
|
175
|
+
}
|
|
176
|
+
function ratechangeCallback() {
|
|
171
177
|
rate.value = toValue(mediaRef)?.playbackRate ?? rate.value;
|
|
172
|
-
}
|
|
173
|
-
|
|
178
|
+
}
|
|
179
|
+
function stalledCallback() {
|
|
174
180
|
stalled.value = true;
|
|
175
|
-
}
|
|
176
|
-
|
|
181
|
+
}
|
|
182
|
+
function suspendCallback() {
|
|
177
183
|
waiting.value = false;
|
|
178
|
-
}
|
|
179
|
-
|
|
184
|
+
}
|
|
185
|
+
function endedCallback() {
|
|
180
186
|
ended.value = true;
|
|
181
|
-
}
|
|
182
|
-
|
|
187
|
+
}
|
|
188
|
+
function pauseCallback() {
|
|
183
189
|
playing.value = false;
|
|
184
190
|
paused.value = true;
|
|
185
|
-
}
|
|
186
|
-
|
|
191
|
+
}
|
|
192
|
+
function playCallback() {
|
|
187
193
|
playing.value = true;
|
|
188
194
|
started.value = true;
|
|
189
|
-
}
|
|
190
|
-
|
|
195
|
+
}
|
|
196
|
+
function volumechangeCallback() {
|
|
191
197
|
const el = toValue(mediaRef);
|
|
192
198
|
if (el) {
|
|
193
199
|
volume.value = el.volume;
|
|
194
200
|
muted.value = el.muted;
|
|
195
201
|
}
|
|
196
|
-
}
|
|
197
|
-
|
|
202
|
+
}
|
|
203
|
+
function errorCallback() {
|
|
198
204
|
const el = toValue(mediaRef);
|
|
199
205
|
if (el?.error) {
|
|
200
206
|
handleMediaElementError(el.error);
|
|
201
207
|
}
|
|
208
|
+
}
|
|
209
|
+
const cancelTimeUpdate = useEventListener(
|
|
210
|
+
mediaRef,
|
|
211
|
+
"timeupdate",
|
|
212
|
+
timeupdateCallback
|
|
213
|
+
);
|
|
214
|
+
const cancelDurationChange = useEventListener(
|
|
215
|
+
mediaRef,
|
|
216
|
+
"durationchange",
|
|
217
|
+
durationChangeCallback
|
|
218
|
+
);
|
|
219
|
+
const cancelProgress = useEventListener(
|
|
220
|
+
mediaRef,
|
|
221
|
+
"progress",
|
|
222
|
+
progressCallback
|
|
223
|
+
);
|
|
224
|
+
const cancelSeeking = useEventListener(mediaRef, "seeking", seekingCallback);
|
|
225
|
+
const cancelSeeked = useEventListener(mediaRef, "seeked", seekedCallback);
|
|
226
|
+
const cancelWaitingLoadstart = useEventListener(
|
|
227
|
+
mediaRef,
|
|
228
|
+
["waiting", "loadstart"],
|
|
229
|
+
waitingLoadstartCallback
|
|
230
|
+
);
|
|
231
|
+
const cancelLoadeddata = useEventListener(
|
|
232
|
+
mediaRef,
|
|
233
|
+
"loadeddata",
|
|
234
|
+
loadeddataCallback
|
|
235
|
+
);
|
|
236
|
+
const cancelPlaying = useEventListener(mediaRef, "playing", playingCallback);
|
|
237
|
+
const cancelRatechange = useEventListener(
|
|
238
|
+
mediaRef,
|
|
239
|
+
"ratechange",
|
|
240
|
+
ratechangeCallback
|
|
241
|
+
);
|
|
242
|
+
const cancelStalled = useEventListener(mediaRef, "stalled", stalledCallback);
|
|
243
|
+
const cancelSuspend = useEventListener(mediaRef, "suspend", suspendCallback);
|
|
244
|
+
const cancelEnded = useEventListener(mediaRef, "ended", endedCallback);
|
|
245
|
+
const cancelPause = useEventListener(mediaRef, "pause", pauseCallback);
|
|
246
|
+
const cancelPlay = useEventListener(mediaRef, "play", playCallback);
|
|
247
|
+
const cancelVolumechange = useEventListener(
|
|
248
|
+
mediaRef,
|
|
249
|
+
"volumechange",
|
|
250
|
+
volumechangeCallback
|
|
251
|
+
);
|
|
252
|
+
const cancelError = useEventListener(mediaRef, "error", errorCallback);
|
|
253
|
+
onScopeDispose(() => {
|
|
254
|
+
cancelTimeUpdate();
|
|
255
|
+
cancelDurationChange();
|
|
256
|
+
cancelProgress();
|
|
257
|
+
cancelSeeking();
|
|
258
|
+
cancelSeeked();
|
|
259
|
+
cancelWaitingLoadstart();
|
|
260
|
+
cancelLoadeddata();
|
|
261
|
+
cancelPlaying();
|
|
262
|
+
cancelRatechange();
|
|
263
|
+
cancelStalled();
|
|
264
|
+
cancelSuspend();
|
|
265
|
+
cancelEnded();
|
|
266
|
+
cancelPause();
|
|
267
|
+
cancelPlay();
|
|
268
|
+
cancelVolumechange();
|
|
269
|
+
cancelError();
|
|
202
270
|
});
|
|
203
271
|
}
|
|
@@ -9,6 +9,5 @@ export type UsePlayerRuntimeArgs = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare function usePlayerRuntime(args: UsePlayerRuntimeArgs): {
|
|
11
11
|
initialize: (autoplay?: boolean) => void;
|
|
12
|
-
destroy: () => void;
|
|
13
12
|
};
|
|
14
13
|
export type UsePlayerRuntimeReturn = ReturnType<typeof usePlayerRuntime>;
|