2.1.2 • Published 4 months ago

nuxt-musicfyplayer v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

musicfyplayer

nuxt-musicfyplayer

npm version npm downloads License Nuxt

Embed a simple HTML music player from local or hosted audio on your Nuxt app using MediaElement.js and ColorThief.js

Quick Setup

  1. Add nuxt-musicfyplayer dependency to your project
# Using pnpm
pnpm add -D nuxt-musicfyplayer

# Using yarn
yarn add --dev nuxt-musicfyplayer

# Using npm
npm install --save-dev nuxt-musicfyplayer
  1. Add nuxt-musicfyplayer to the modules section of nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    'nuxt-musicfyplayer'
  ]
})

That's it! You can now use nuxt-musicfyplayer in your Nuxt app ✨

Usage

In the project, use the component <MusicfyPlayer :config="" />, where config is the configuration options of the player.

Component properties

Size properties

PropertyDescriptionDefault value
configMusicfyPlayer composable
widthMusic player width100%
heightMusic player height450px

MusicfyPlayer composable

Define your configuration options with the useMusicfyPlayer composable.

PropertyDescription
audioThe audio source properties
imageThe image source (preferably squared)
colorColor options

Audio shared properties

PropertyDescriptionDefault value
providerProvider of the audio source.local
typeContent-type fo the audio sourceaudio/mpeg
preloadPreload the audio sourceauto
...Selected audio provider properties

Supported audio providers

ProviderValue
URLlocal
Dropboxdropbox

Local audio properties

Audio propertyDescriptionRequired
srcAudio source linkYes

Dropbox audio properties

Audio propertyDescriptionRequired
idFile identifierYes
rlkeyNew file identifier paramNo

Image properties

PropertyDescriptionRequired
srcImage source linkYes
altImage alternative textNo

Color properties

PropertyDescriptionDefault value
classA custom class for your player's background colormusicfyplayer-color
detectDetect the dominant color from the image source and use it as the player's background colorfalse

Example

Use the useMusicfyPlayer composable to define the configuration options of the player.

<script setup lang="ts">
const config = useMusicfyPlayer({
  audio: {
    provider: "dropbox",
    preload: "none",
    id: "soep3xvq8aee4eh6hcj4r",
    rlkey: "g7sqo9y5zl3f69oxftzo5auc5"
  },
  image: {
    src: "https://dimatis.yizack.com/images/reminiscences.jpg",
    alt: "Dimatis - Reminiscences"
  },
  color: {
    detect: true
  }
})
</script>

<template>
  <MusicfyPlayer :config="config" width="100%" />
</template>

More examples

Example of use on a website: Dimatis Website

Live Demo

Live Demo

Check out the 🏀 Online playground for more examples.

Credits

Development

# Install dependencies
npm install

# Generate type stubs
npm run dev:prepare

# Develop with the playground
npm run dev

# Build the playground
npm run dev:build

# Run ESLint
npm run lint

# Run Vitest
npm run test
npm run test:watch

# Release new version
npm run release
2.1.2

4 months ago

2.0.3

10 months ago

2.1.1

8 months ago

2.0.2

10 months ago

2.1.0

10 months ago

2.0.1

10 months ago

2.0.0

12 months ago

1.0.1

1 year ago

1.0.0

1 year ago