@maas/vue-equipment 0.24.0 → 0.24.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/plugins/MagicPlayer/src/components/MagicAudioPlayerControls.vue +0 -4
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerCurrentTime.vue +29 -25
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.d.ts +0 -5
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +1 -9
- package/dist/plugins/MagicPlayer/src/composables/usePlayerApi.d.ts +0 -5
- package/package.json +1 -1
package/dist/nuxt/module.json
CHANGED
|
@@ -14,41 +14,45 @@ interface Props {
|
|
|
14
14
|
|
|
15
15
|
const props = defineProps<Props>()
|
|
16
16
|
|
|
17
|
-
const {
|
|
17
|
+
const { currentTime } = usePlayerMediaApi({
|
|
18
18
|
id: props.id,
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
}
|
|
21
|
+
function toNumber(value: string | number): number {
|
|
22
|
+
return typeof value === 'string' ? parseFloat(value) : Number(value)
|
|
23
|
+
}
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const formatTime = function (seconds: number, guide: number) {
|
|
26
|
+
seconds = seconds < 0 ? 0 : seconds
|
|
27
|
+
let s: string | number = Math.floor(seconds % 60)
|
|
28
|
+
let m: string | number = Math.floor((seconds / 60) % 60)
|
|
29
|
+
let h: string | number = Math.floor(seconds / 3600)
|
|
30
|
+
const gm = Math.floor((guide / 60) % 60)
|
|
31
|
+
const gh = Math.floor(guide / 3600)
|
|
32
|
+
|
|
33
|
+
// handle invalid times
|
|
34
|
+
if (isNaN(seconds) || seconds === Infinity) {
|
|
35
|
+
// '-' is false for all relational operators (e.g. <, >=) so this setting
|
|
36
|
+
// will add the minimum number of fields specified by the guide
|
|
37
|
+
h = m = s = '-'
|
|
38
|
+
}
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
40
|
+
// Check if we need to show hours
|
|
41
|
+
h = toNumber(h) > 0 || gh > 0 ? h + ':' : ''
|
|
32
42
|
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
// If hours are showing, we may need to add a leading zero.
|
|
44
|
+
// Always show at least one digit of minutes.
|
|
45
|
+
m = ((h || gm >= 10) && toNumber(m) < 10 ? '0' + m : m) + ':'
|
|
35
46
|
|
|
36
|
-
if
|
|
37
|
-
|
|
38
|
-
} else {
|
|
39
|
-
time += `${minutes.value}`
|
|
40
|
-
}
|
|
47
|
+
// Check if leading zero is need for seconds
|
|
48
|
+
s = toNumber(s) < 10 ? '0' + s : s
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} else {
|
|
45
|
-
time += `:${seconds.value}`
|
|
46
|
-
}
|
|
50
|
+
return h + m + s
|
|
51
|
+
}
|
|
47
52
|
|
|
48
|
-
|
|
49
|
-
})
|
|
53
|
+
const stringifiedTime = computed(() => formatTime(currentTime.value, 60))
|
|
50
54
|
</script>
|
|
51
55
|
|
|
52
56
|
<style>
|
|
53
|
-
:root{--magic-player-current-time-font-size:0.875rem;--magic-player-current-time-color:inherit;--magic-player-current-time-width:3.
|
|
57
|
+
:root{--magic-player-current-time-font-size:0.875rem;--magic-player-current-time-color:inherit;--magic-player-current-time-width:3.25rem;--magic-player-current-time-justify-content:flex-start}.magic-player-current-time{align-items:center;color:var(--magic-player-current-time-color);display:flex;font-size:var(--magic-player-current-time-font-size);height:100%;justify-content:var(--magic-player-current-time-justify-content);width:var(--magic-player-current-time-width)}
|
|
54
58
|
</style>
|
|
@@ -5,11 +5,6 @@ export type UsePlayerMediaApiArgs = {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function usePlayerMediaApi(args: UsePlayerMediaApiArgs): {
|
|
7
7
|
currentTime: import("vue").Ref<number>;
|
|
8
|
-
formattedCurrentTime: import("vue").ComputedRef<{
|
|
9
|
-
hours: number;
|
|
10
|
-
minutes: number;
|
|
11
|
-
seconds: number;
|
|
12
|
-
}>;
|
|
13
8
|
duration: import("vue").Ref<number>;
|
|
14
9
|
seeking: import("vue").Ref<boolean>;
|
|
15
10
|
volume: import("vue").Ref<number>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref,
|
|
1
|
+
import { ref, watch, unref, toValue } from "vue";
|
|
2
2
|
import { useEventListener, watchIgnorable } from "@vueuse/core";
|
|
3
3
|
import { usePlayerStateEmitter } from "./usePlayerStateEmitter.mjs";
|
|
4
4
|
export function usePlayerMediaApi(args) {
|
|
@@ -14,13 +14,6 @@ export function usePlayerMediaApi(args) {
|
|
|
14
14
|
const buffered = ref([]);
|
|
15
15
|
const muted = ref(false);
|
|
16
16
|
const { mediaRef } = args;
|
|
17
|
-
const formattedCurrentTime = computed(() => formatTime(currentTime.value));
|
|
18
|
-
function formatTime(currentTime2) {
|
|
19
|
-
const hours = Math.floor(currentTime2 / 3600);
|
|
20
|
-
const minutes = Math.floor(currentTime2 % 3600 / 60);
|
|
21
|
-
const seconds = Math.floor(currentTime2 % 60);
|
|
22
|
-
return { hours, minutes, seconds };
|
|
23
|
-
}
|
|
24
17
|
function timeRangeToArray(timeRanges) {
|
|
25
18
|
let ranges = [];
|
|
26
19
|
for (let i = 0; i < timeRanges.length; ++i)
|
|
@@ -256,7 +249,6 @@ export function usePlayerMediaApi(args) {
|
|
|
256
249
|
});
|
|
257
250
|
return {
|
|
258
251
|
currentTime,
|
|
259
|
-
formattedCurrentTime,
|
|
260
252
|
duration,
|
|
261
253
|
seeking,
|
|
262
254
|
volume,
|
|
@@ -5,11 +5,6 @@ type usePlayerApiArgs = {
|
|
|
5
5
|
export declare function usePlayerApi(args: usePlayerApiArgs): {
|
|
6
6
|
mediaApi: {
|
|
7
7
|
currentTime: import("vue").Ref<number>;
|
|
8
|
-
formattedCurrentTime: import("vue").ComputedRef<{
|
|
9
|
-
hours: number;
|
|
10
|
-
minutes: number;
|
|
11
|
-
seconds: number;
|
|
12
|
-
}>;
|
|
13
8
|
duration: import("vue").Ref<number>;
|
|
14
9
|
seeking: import("vue").Ref<boolean>;
|
|
15
10
|
volume: import("vue").Ref<number>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maas/vue-equipment",
|
|
3
3
|
"description": "A magic collection of Vue composables, plugins, components and directives",
|
|
4
|
-
"version": "0.24.
|
|
4
|
+
"version": "0.24.1",
|
|
5
5
|
"author": "Robin Scholz <https://github.com/robinscholz>, Christoph Jeworutzki <https://github.com/ChristophJeworutzki>",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@antfu/ni": "^0.21.12",
|