nuxt-musicfyplayer 2.1.3 → 2.1.5
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 +2 -2
- package/dist/module.json +2 -2
- package/dist/module.mjs +2 -6
- package/dist/runtime/components/MusicfyPlayer.vue +4 -9
- package/dist/runtime/types/mediaelement.d.ts +6 -0
- package/dist/runtime/utils/average-color.d.ts +1 -0
- package/dist/runtime/utils/average-color.js +16 -0
- package/dist/runtime/utils/mediaelement.d.ts +1 -6
- package/package.json +3 -3
- package/dist/runtime/types/colorthief.d.ts +0 -9
package/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
[![License][license-src]][license-href]
|
8
8
|
[![Nuxt][nuxt-src]][nuxt-href]
|
9
9
|
|
10
|
-
Embed a simple HTML music player from local or hosted audio on your Nuxt app using MediaElement.js and
|
10
|
+
Embed a simple HTML music player from local or hosted audio on your Nuxt app using MediaElement.js and fast-average-color
|
11
11
|
|
12
12
|
- [✨ Release Notes](https://github.com/Yizack/nuxt-musicfyplayer/blob/main/CHANGELOG.md)
|
13
13
|
- [🏀 Online playground](https://stackblitz.com/github/yizack/nuxt-musicfyplayer?file=playground%2Fapp.vue)
|
@@ -146,7 +146,7 @@ Check out the [🏀 Online playground](https://stackblitz.com/github/yizack/nuxt
|
|
146
146
|
|
147
147
|
## Credits
|
148
148
|
|
149
|
-
- Detect
|
149
|
+
- Detect average color with [fast-average-color](https://github.com/fast-average-color/fast-average-color)
|
150
150
|
- Music player controls by [MediaElement.js](https://www.mediaelementjs.com/)
|
151
151
|
- [Nuxt](https://github.com/nuxt/nuxt), the JavaScript framework for creating SSR Vue applications and its [Module Author Guide](https://nuxt.com/docs/guide/going-further/modules)
|
152
152
|
|
package/dist/module.json
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "nuxt-musicfyplayer",
|
3
|
-
"configKey": "
|
3
|
+
"configKey": "musicfyplayer",
|
4
4
|
"compatibility": {
|
5
5
|
"nuxt": ">=3.0.0"
|
6
6
|
},
|
7
|
-
"version": "2.1.
|
7
|
+
"version": "2.1.5",
|
8
8
|
"builder": {
|
9
9
|
"@nuxt/module-builder": "1.0.0",
|
10
10
|
"unbuild": "3.5.0"
|
package/dist/module.mjs
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { defineNuxtModule, createResolver, addComponent, addImportsDir
|
1
|
+
import { defineNuxtModule, createResolver, addComponent, addImportsDir } from '@nuxt/kit';
|
2
2
|
|
3
3
|
const module = defineNuxtModule({
|
4
4
|
meta: {
|
5
5
|
name: "nuxt-musicfyplayer",
|
6
|
-
configKey: "
|
6
|
+
configKey: "musicfyplayer",
|
7
7
|
compatibility: {
|
8
8
|
nuxt: ">=3.0.0"
|
9
9
|
}
|
@@ -16,10 +16,6 @@ const module = defineNuxtModule({
|
|
16
16
|
filePath: resolve("./runtime/components/MusicfyPlayer.vue")
|
17
17
|
});
|
18
18
|
addImportsDir(resolve("./runtime/composables"));
|
19
|
-
addTypeTemplate({
|
20
|
-
filename: "types/colorthief.d.ts",
|
21
|
-
src: resolve("./runtime/types/colorthief.d.ts")
|
22
|
-
});
|
23
19
|
}
|
24
20
|
});
|
25
21
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<script setup>
|
2
|
-
import
|
2
|
+
import { getImageAverageColor } from "./../utils/average-color";
|
3
3
|
import { onMounted, ref, useTemplateRef } from "#imports";
|
4
4
|
const props = defineProps({
|
5
5
|
config: {
|
@@ -21,14 +21,9 @@ const audio = useTemplateRef("audio");
|
|
21
21
|
const size = ref({ width: props.width, height: props.height });
|
22
22
|
const backgroundColor = ref();
|
23
23
|
if (import.meta.client && props.config.colorDetect) {
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
};
|
24
|
+
getImageAverageColor(props.config.imageSrc).then((color) => {
|
25
|
+
backgroundColor.value = color;
|
26
|
+
}).catch(console.error);
|
32
27
|
}
|
33
28
|
onMounted(async () => {
|
34
29
|
if (!audio.value) return;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getImageAverageColor: (src: string) => Promise<string>;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { FastAverageColor } from "fast-average-color";
|
2
|
+
const fac = new FastAverageColor();
|
3
|
+
export const getImageAverageColor = (src) => {
|
4
|
+
return new Promise((resolve, reject) => {
|
5
|
+
const img = new Image();
|
6
|
+
img.crossOrigin = "Anonymous";
|
7
|
+
img.src = src;
|
8
|
+
img.onload = () => {
|
9
|
+
const color = fac.getColor(img);
|
10
|
+
resolve(color.rgb);
|
11
|
+
};
|
12
|
+
img.onerror = () => {
|
13
|
+
reject(new Error(`Failed to load image: ${src}`));
|
14
|
+
};
|
15
|
+
});
|
16
|
+
};
|
@@ -1,8 +1,3 @@
|
|
1
1
|
import 'mediaelement/build/mediaelement-and-player.js';
|
2
|
-
import type {
|
3
|
-
declare global {
|
4
|
-
interface Window {
|
5
|
-
MediaElementPlayer: MediaElementPlayer | undefined;
|
6
|
-
}
|
7
|
-
}
|
2
|
+
import type { MediaElementPlayerOptions } from '../types/mediaelement.js';
|
8
3
|
export declare const mediaElementPlayer: (element: HTMLAudioElement, options: MediaElementPlayerOptions) => void;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "nuxt-musicfyplayer",
|
3
|
-
"version": "2.1.
|
4
|
-
"description": "Embed a simple and beautiful HTML music player from local or hosted audio on your website using MediaElement.js and
|
3
|
+
"version": "2.1.5",
|
4
|
+
"description": "Embed a simple and beautiful HTML music player from local or hosted audio on your website using MediaElement.js and fast-average-color",
|
5
5
|
"keywords": [
|
6
6
|
"nuxt",
|
7
7
|
"nuxt3",
|
@@ -44,7 +44,7 @@
|
|
44
44
|
},
|
45
45
|
"dependencies": {
|
46
46
|
"@nuxt/kit": "^3.16.2",
|
47
|
-
"
|
47
|
+
"fast-average-color": "^9.5.0",
|
48
48
|
"mediaelement": "^7.0.7"
|
49
49
|
},
|
50
50
|
"devDependencies": {
|
@@ -1,9 +0,0 @@
|
|
1
|
-
declare module 'colorthief' {
|
2
|
-
type Palette = [red: number, green: number, blue: number]
|
3
|
-
export default class ColorThief {
|
4
|
-
getColor(sourceImage: HTMLImageElement, quality?: number): Palette
|
5
|
-
static getColor(sourceImage: string, quality?: number): Promise<Palette>
|
6
|
-
getPaletteFromURL(URL: string, colorCount?: number, quality?: number): Promise<Palette[]>
|
7
|
-
getColorFromURL(imageURL: string, quality?: number): Promise<Palette>
|
8
|
-
}
|
9
|
-
}
|