Skip to content
Audio library designed for UI sound effects
JavaScript
Branch: master
Clone or download
Latest commit 02318e4 Oct 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build patch Aug 15, 2019
src patch Aug 15, 2019
test first May 19, 2019
.babelrc first May 19, 2019
.eslintrc first May 19, 2019
.gitignore
.npmignore first May 19, 2019
.travis.yml first May 19, 2019
CHANGELOG.md first May 19, 2019
LICENSE Create LICENSE Oct 16, 2019
README.md typo Aug 15, 2019
logo.png update readme Aug 15, 2019
package-lock.json Merge pull request #4 from wle8300/dependabot/npm_and_yarn/eslint-4.18.2 Oct 16, 2019
package.json Merge pull request #4 from wle8300/dependabot/npm_and_yarn/eslint-4.18.2 Oct 16, 2019

README.md

uifx is a library for playing sound fx on the web.




Demo

https://wle8300.github.io/uifx-demo/

Usage

npm install --save uifx
import UIfx from 'uifx'
import bellAudio from './my-sounds/bell.mp3'

const bell = new UIfx(
  bellAudio,
  {
    volume: 0.4, // number between 0.0 ~ 1.0
    throttleMs: 100
  }
)

// playback
bell.play()

// temporarily change volume
bell.play(0.25) // will play at 0.25 volume
bell.play() // reverts back to 0.4 volume

// set volume
bell.setVolume(0.5)
bell.play()

// ...chainable
bell.setVolume(0.5).play()

Technical

It uses the HTMLAudioElement API so it's available for all major desktop/mobile browsers. It also preloads audio files so sounds are immediately ready for playback.

Even though UIfx will preload audio over the network, it's usually advisable to package your audio files locally since you don't want to rely on a 3rd-party to host your audio files.

The library has zero dependencies.

Why use UIfx?

It's designed specifically for soundfx so it preloads audio files to ensure it's immediately playable, and will spawns an audio player for each playback. This makes it lightweight and performant when compared to fully-fledged libraries like SoundManager or Howler.

You can’t perform that action at this time.