nuxt-musicfyplayer 2.1.1 → 2.1.3
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/README.md +6 -6
- package/dist/module.d.mts +2 -1
- package/dist/module.json +3 -3
- package/dist/runtime/components/MusicfyPlayer.vue +52 -70
- package/dist/runtime/components/MusicfyPlayer.vue.d.ts +22 -0
- package/dist/runtime/composables/musicfyplayer.d.ts +9 -2
- package/dist/runtime/composables/musicfyplayer.js +4 -14
- package/dist/runtime/types/musicfyplayer.d.ts +9 -22
- package/dist/runtime/types/providers.d.ts +14 -0
- package/dist/runtime/utils/sources.d.ts +2 -0
- package/dist/runtime/utils/sources.js +13 -0
- package/dist/types.d.mts +3 -1
- package/package.json +21 -29
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -7
- package/dist/types.d.ts +0 -1
package/README.md
CHANGED
@@ -49,13 +49,13 @@ In the project, use the component `<MusicfyPlayer :config="" />`, where `config`
|
|
49
49
|
|
50
50
|
| Property | Description | Default value |
|
51
51
|
|---------------------------------------|--------------------------|---------------|
|
52
|
-
| [`config`](#musicfyplayer-
|
52
|
+
| [`config`](#musicfyplayer-composable) | MusicfyPlayer composable | |
|
53
53
|
| `width` | Music player width | `100%` |
|
54
54
|
| `height` | Music player height | `450px` |
|
55
55
|
|
56
|
-
## MusicfyPlayer
|
56
|
+
## MusicfyPlayer composable
|
57
57
|
|
58
|
-
Define your configuration options with the `
|
58
|
+
Define your configuration options with the `useMusicfyPlayer` composable.
|
59
59
|
|
60
60
|
| Property | Description |
|
61
61
|
|-------------------------------------|---------------------------------------|
|
@@ -108,11 +108,11 @@ Define your configuration options with the `defineMusicfyPlayer` composable.
|
|
108
108
|
|
109
109
|
## Example
|
110
110
|
|
111
|
-
Use the
|
111
|
+
Use the `useMusicfyPlayer` composable to define the configuration options of the player.
|
112
112
|
|
113
113
|
```html
|
114
114
|
<script setup lang="ts">
|
115
|
-
const config =
|
115
|
+
const config = useMusicfyPlayer({
|
116
116
|
audio: {
|
117
117
|
provider: "dropbox",
|
118
118
|
preload: "none",
|
@@ -120,7 +120,7 @@ const config = defineMusicfyPlayer({
|
|
120
120
|
rlkey: "g7sqo9y5zl3f69oxftzo5auc5"
|
121
121
|
},
|
122
122
|
image: {
|
123
|
-
src: "https://dimatis.
|
123
|
+
src: "https://dimatis.music/images/reminiscences.jpg",
|
124
124
|
alt: "Dimatis - Reminiscences"
|
125
125
|
},
|
126
126
|
color: {
|
package/dist/module.d.mts
CHANGED
package/dist/module.json
CHANGED
@@ -1,70 +1,52 @@
|
|
1
|
-
<script setup
|
2
|
-
import ColorThief from
|
3
|
-
import
|
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
|
-
|
30
|
-
})
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
generateColor()
|
51
|
-
|
52
|
-
onMounted(async () => {
|
53
|
-
const { mediaElementPlayer } = await import('./../utils/mediaelement')
|
54
|
-
mediaElementPlayer(audio.value, {
|
55
|
-
iconSprite: '',
|
56
|
-
audioHeight: 40,
|
57
|
-
features: ['playpause', 'current', 'duration', 'progress', 'volume', 'tracks', 'fullscreen'],
|
58
|
-
alwaysShowControls: true,
|
59
|
-
timeAndDurationSeparator: '<span></span>',
|
60
|
-
iPadUseNativeControls: false,
|
61
|
-
iPhoneUseNativeControls: false,
|
62
|
-
AndroidUseNativeControls: false,
|
63
|
-
})
|
64
|
-
})
|
65
|
-
</script>
|
66
|
-
|
67
|
-
<template>
|
1
|
+
<script setup>
|
2
|
+
import ColorThief from "colorthief";
|
3
|
+
import { onMounted, ref, useTemplateRef } from "#imports";
|
4
|
+
const props = defineProps({
|
5
|
+
config: {
|
6
|
+
type: Object,
|
7
|
+
required: true
|
8
|
+
},
|
9
|
+
width: {
|
10
|
+
type: String,
|
11
|
+
required: false,
|
12
|
+
default: "100%"
|
13
|
+
},
|
14
|
+
height: {
|
15
|
+
type: String,
|
16
|
+
required: false,
|
17
|
+
default: "450px"
|
18
|
+
}
|
19
|
+
});
|
20
|
+
const audio = useTemplateRef("audio");
|
21
|
+
const size = ref({ width: props.width, height: props.height });
|
22
|
+
const backgroundColor = ref();
|
23
|
+
if (import.meta.client && props.config.colorDetect) {
|
24
|
+
const img = new Image();
|
25
|
+
img.crossOrigin = "Anonymous";
|
26
|
+
img.src = props.config.imageSrc;
|
27
|
+
img.onload = () => {
|
28
|
+
const colorThief = new ColorThief();
|
29
|
+
const color = colorThief.getColor(img);
|
30
|
+
backgroundColor.value = color ? `rgb(${color[0]}, ${color[1]}, ${color[2]})` : void 0;
|
31
|
+
};
|
32
|
+
}
|
33
|
+
onMounted(async () => {
|
34
|
+
if (!audio.value) return;
|
35
|
+
const { mediaElementPlayer } = await import("./../utils/mediaelement");
|
36
|
+
mediaElementPlayer(audio.value, {
|
37
|
+
iconSprite: "",
|
38
|
+
audioHeight: 40,
|
39
|
+
features: ["playpause", "current", "duration", "progress", "volume", "tracks", "fullscreen"],
|
40
|
+
alwaysShowControls: true,
|
41
|
+
timeAndDurationSeparator: "<span></span>",
|
42
|
+
iPadUseNativeControls: false,
|
43
|
+
iPhoneUseNativeControls: false,
|
44
|
+
AndroidUseNativeControls: false
|
45
|
+
});
|
46
|
+
});
|
47
|
+
</script>
|
48
|
+
|
49
|
+
<template>
|
68
50
|
<div class="musicfyplayer" :class="{ [`${config.colorClass}`]: config.colorClass }" :style="{ ...size, backgroundColor }">
|
69
51
|
<div class="mp__box">
|
70
52
|
<div class="mp__controls">
|
@@ -83,8 +65,8 @@ onMounted(async () => {
|
|
83
65
|
</div>
|
84
66
|
</div>
|
85
67
|
</div>
|
86
|
-
</template>
|
87
|
-
|
68
|
+
</template>
|
69
|
+
|
88
70
|
<style>
|
89
71
|
@import "./../assets/css/musicfyplayer.css";
|
90
|
-
</style>
|
72
|
+
</style>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type { MusicfyPlayerConfig } from './../types/musicfyplayer.js';
|
2
|
+
type __VLS_Props = {
|
3
|
+
/**
|
4
|
+
* The configuration of the player
|
5
|
+
*/
|
6
|
+
config: MusicfyPlayerConfig;
|
7
|
+
/**
|
8
|
+
* The width and height of the player
|
9
|
+
* @default '100%'
|
10
|
+
*/
|
11
|
+
width?: string;
|
12
|
+
/**
|
13
|
+
* The height of the player
|
14
|
+
* @default '450px'
|
15
|
+
*/
|
16
|
+
height?: string;
|
17
|
+
};
|
18
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
19
|
+
width: string;
|
20
|
+
height: string;
|
21
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
22
|
+
export default _default;
|
@@ -1,2 +1,9 @@
|
|
1
|
-
import type {
|
2
|
-
|
1
|
+
import type { Providers } from '../types/providers.js';
|
2
|
+
import type { MusicfyPlayerConfig, MusicfyPlayerComposableConfig } from './../types/musicfyplayer.js';
|
3
|
+
/**
|
4
|
+
* Musicfy Player composable
|
5
|
+
* @param config - Musicfy Player composable configuration
|
6
|
+
* @returns Musicfy Player configuration
|
7
|
+
*/
|
8
|
+
export declare const useMusicfyPlayer: <T extends keyof Providers = "local">(config: MusicfyPlayerComposableConfig<T>) => MusicfyPlayerConfig;
|
9
|
+
export declare const defineMusicfyPlayer: <T extends keyof Providers = "local">(config: MusicfyPlayerComposableConfig<T>) => MusicfyPlayerConfig;
|
@@ -1,20 +1,9 @@
|
|
1
|
+
import { getSource } from "../utils/sources.js";
|
1
2
|
import { ref } from "#imports";
|
2
|
-
const
|
3
|
-
const dropboxBase = "https://www.dropbox.com";
|
4
|
-
return rlkey ? `${dropboxBase}/scl/fi/${id}/?rlkey=${rlkey}&dl=1` : `${dropboxBase}/s/${id}?dl=1`;
|
5
|
-
};
|
6
|
-
export const defineMusicfyPlayer = (config) => {
|
3
|
+
export const useMusicfyPlayer = (config) => {
|
7
4
|
const audioSrc = ref();
|
8
5
|
const provider = config.audio.provider || "local";
|
9
|
-
|
10
|
-
default:
|
11
|
-
case "local":
|
12
|
-
audioSrc.value = config.audio.src;
|
13
|
-
break;
|
14
|
-
case "dropbox":
|
15
|
-
audioSrc.value = srcDropbox(config.audio.id, config.audio.rlkey);
|
16
|
-
break;
|
17
|
-
}
|
6
|
+
audioSrc.value = getSource(provider, config.audio);
|
18
7
|
if (!audioSrc.value) throw new Error("Invalid audio source");
|
19
8
|
return {
|
20
9
|
imageSrc: config.image.src,
|
@@ -26,3 +15,4 @@ export const defineMusicfyPlayer = (config) => {
|
|
26
15
|
colorDetect: config.color?.detect || false
|
27
16
|
};
|
28
17
|
};
|
18
|
+
export const defineMusicfyPlayer = useMusicfyPlayer;
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
import type { Providers } from './providers'
|
2
|
+
|
3
|
+
export interface MusicfyPlayerComposableConfig<T extends keyof Providers> {
|
2
4
|
/**
|
3
5
|
* Image configuration
|
4
6
|
*/
|
@@ -10,12 +12,15 @@ export interface MusicfyPlayerDefinition {
|
|
10
12
|
*/
|
11
13
|
alt?: string
|
12
14
|
}
|
15
|
+
/**
|
16
|
+
* Audio configuration
|
17
|
+
*/
|
13
18
|
audio: {
|
14
19
|
/**
|
15
20
|
* Audio provider
|
16
21
|
* @default 'local'
|
17
22
|
*/
|
18
|
-
provider?:
|
23
|
+
provider?: T
|
19
24
|
/**
|
20
25
|
* Audio type
|
21
26
|
* @default 'audio/mpeg'
|
@@ -26,7 +31,7 @@ export interface MusicfyPlayerDefinition {
|
|
26
31
|
* @default 'auto'
|
27
32
|
*/
|
28
33
|
preload?: 'auto' | 'metadata' | 'none'
|
29
|
-
} &
|
34
|
+
} & Providers[T]
|
30
35
|
/**
|
31
36
|
* Color configuration
|
32
37
|
*/
|
@@ -44,30 +49,12 @@ export interface MusicfyPlayerDefinition {
|
|
44
49
|
}
|
45
50
|
}
|
46
51
|
|
47
|
-
export interface LocalAudio {
|
48
|
-
provider?: 'local'
|
49
|
-
/**
|
50
|
-
* Path to the audio file
|
51
|
-
* @example '/path/to/audio.mp3'
|
52
|
-
* @example 'https://example.com/audio.mp3'
|
53
|
-
*/
|
54
|
-
src: string
|
55
|
-
}
|
56
|
-
|
57
|
-
export interface DropboxAudio {
|
58
|
-
provider?: 'dropbox'
|
59
|
-
id: string
|
60
|
-
rlkey?: string
|
61
|
-
}
|
62
|
-
|
63
|
-
export type AudioConfig = LocalAudio | DropboxAudio
|
64
|
-
|
65
52
|
export interface MusicfyPlayerConfig {
|
66
53
|
imageSrc: string
|
67
54
|
imageAlt: string
|
68
55
|
audioType: string
|
69
56
|
audioSrc: string
|
70
|
-
audioPreload:
|
57
|
+
audioPreload: MusicfyPlayerComposableConfig['audio']['preload']
|
71
58
|
colorClass: string
|
72
59
|
colorDetect: boolean
|
73
60
|
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const getDropboxSource = (id, rlkey) => {
|
2
|
+
const dropboxBase = "https://www.dropbox.com";
|
3
|
+
return rlkey ? `${dropboxBase}/scl/fi/${id}/?rlkey=${rlkey}&dl=1` : `${dropboxBase}/s/${id}?dl=1`;
|
4
|
+
};
|
5
|
+
export const getSource = (provider, config) => {
|
6
|
+
switch (provider) {
|
7
|
+
default:
|
8
|
+
case "local":
|
9
|
+
return config.src;
|
10
|
+
case "dropbox":
|
11
|
+
return getDropboxSource(config.id, config.rlkey);
|
12
|
+
}
|
13
|
+
};
|
package/dist/types.d.mts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nuxt-musicfyplayer",
|
3
|
-
"version": "2.1.
|
3
|
+
"version": "2.1.3",
|
4
4
|
"description": "Embed a simple and beautiful HTML music player from local or hosted audio on your website using MediaElement.js and ColorThief.js",
|
5
5
|
"keywords": [
|
6
6
|
"nuxt",
|
@@ -16,19 +16,17 @@
|
|
16
16
|
"author": {
|
17
17
|
"name": "Yizack Rangel",
|
18
18
|
"email": "yizackr@gmail.com",
|
19
|
-
"url": "https://yizack.com
|
19
|
+
"url": "https://yizack.com"
|
20
20
|
},
|
21
21
|
"license": "MIT",
|
22
22
|
"type": "module",
|
23
23
|
"exports": {
|
24
24
|
".": {
|
25
|
-
"types": "./dist/types.d.
|
26
|
-
"import": "./dist/module.mjs"
|
27
|
-
"require": "./dist/module.cjs"
|
25
|
+
"types": "./dist/types.d.mts",
|
26
|
+
"import": "./dist/module.mjs"
|
28
27
|
}
|
29
28
|
},
|
30
|
-
"main": "./dist/module.
|
31
|
-
"types": "./dist/types.d.ts",
|
29
|
+
"main": "./dist/module.mjs",
|
32
30
|
"files": [
|
33
31
|
"dist"
|
34
32
|
],
|
@@ -39,34 +37,28 @@
|
|
39
37
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
40
38
|
"release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
41
39
|
"lint": "eslint .",
|
40
|
+
"lint:fix": "eslint . --fix",
|
42
41
|
"test": "echo \"Error: no test specified\"",
|
43
42
|
"test:types": "vue-tsc --noEmit",
|
44
43
|
"test:watch": "vitest watch"
|
45
44
|
},
|
46
45
|
"dependencies": {
|
47
|
-
"@nuxt/kit": "^3.
|
46
|
+
"@nuxt/kit": "^3.16.2",
|
48
47
|
"colorthief": "2.4.0",
|
49
|
-
"mediaelement": "^7.0.
|
48
|
+
"mediaelement": "^7.0.7"
|
50
49
|
},
|
51
50
|
"devDependencies": {
|
52
|
-
"@nuxt/devtools": "^
|
53
|
-
"@nuxt/eslint-config": "^
|
54
|
-
"@nuxt/module-builder": "^0.
|
55
|
-
"@nuxt/schema": "^3.
|
56
|
-
"@nuxt/test-utils": "^3.
|
57
|
-
"@types/node": "^22.
|
58
|
-
"changelogen": "^0.
|
59
|
-
"eslint": "^9.
|
60
|
-
"nuxt": "^3.
|
61
|
-
"vitest": "^
|
62
|
-
"vue-tsc": "^2.
|
51
|
+
"@nuxt/devtools": "^2.3.2",
|
52
|
+
"@nuxt/eslint-config": "^1.3.0",
|
53
|
+
"@nuxt/module-builder": "^1.0.0",
|
54
|
+
"@nuxt/schema": "^3.16.2",
|
55
|
+
"@nuxt/test-utils": "^3.17.2",
|
56
|
+
"@types/node": "^22.14.0",
|
57
|
+
"changelogen": "^0.6.1",
|
58
|
+
"eslint": "^9.24.0",
|
59
|
+
"nuxt": "^3.16.2",
|
60
|
+
"vitest": "^3.1.1",
|
61
|
+
"vue-tsc": "^2.2.8"
|
63
62
|
},
|
64
|
-
"
|
65
|
-
|
66
|
-
"repo": "Yizack/nuxt-musicfyplayer",
|
67
|
-
"provider": "github",
|
68
|
-
"domain": "github.com"
|
69
|
-
}
|
70
|
-
},
|
71
|
-
"packageManager": "pnpm@9.12.1"
|
72
|
-
}
|
63
|
+
"packageManager": "pnpm@10.7.1"
|
64
|
+
}
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
package/dist/types.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export { type ModuleOptions, default } from './module'
|