Skip to content

๐Ÿ”Š A Nuxt module for playing sound effects (forked)

License

Notifications You must be signed in to change notification settings

IJsfontein/nuxt-use-sound

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

60 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”Š nuxt-use-sound

This module is a Nuxt implementation of the Vue composable @vueuse/sound.

For a better understanding of this module, you should check out the original composable page.

Setup

In order to use this module, you must have @nuxt/composition-api setup in your project.

Once you installed it, add nuxt-use-sound dependency to your project

yarn add --dev nuxt-use-sound
# or
npm i -D nuxt-use-sound

Add nuxt-use-sound to the modules section of nuxt.config.js

// nuxt.config.js
{
  buildModules: ['nuxt-use-sound']
}

Configure your sounds ๐Ÿฅ

// nuxt.config.js
{
  sound: {
    back: {
      src: "/back.wav",
      options: {
        volume: 0.25
      }
    }
  }
}

The rest of the documentation is available on the original composable repository.

Usage

Play your sounds, anywhere in your app.

Just note that no sound can be played before the user has clicked the page, this is a limitation from the Web Audio API.

<template>
  <button @click="$sounds.back.play">
    Boop! ๐ŸŽบ
  </button>
</template>

Development

  1. Clone this repository
  2. Install dependencies using yarn install
  3. Start development server using yarn dev

License

MIT License

Credits

This package comes from @vueuse/sound, a package inspired by the React hook, useSound.

All the credit behind this idea goes to Josh W. Comeau.

About

๐Ÿ”Š A Nuxt module for playing sound effects (forked)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 53.0%
  • JavaScript 43.5%
  • Vue 3.5%