开发者社区> 镜像站> NPM> sound-effect-manager
sound-effect-manager
Easy way to manage and play sound effects using HTML5 Web Audio API
Last updated 5 years ago by henrikjoreteg .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install sound-effect-manager 
SYNC missed versions from official npm registry.

SoundEffectManager

Is just that. It's a simple sound effect manager for playing sounds using the awesome HTML 5 Web Audio API.

If you think I'm talking about <audio> tags, go read this: http://www.html5rocks.com/en/tutorials/webaudio/intro/

It's significantly better than <audio> tags for several reasons:

  • You don't have to create a tag for each sound you want to play
  • You can multiplex an effect without having to create duplicate tags
  • You can also control volume and add other effects

Part of the Ampersand.js toolkit for building clientside applications.

Installing

npm install sound-effect-manager

Using it

// just init the sound effect manager
var SoundEffectManager = require('sound-effect-manager');

var sm = new SoundEffectManager();

// load some files by passing it a url and a name
sm.loadFile('taps.mp3', 'taps');
sm.loadFile('rocket.wav', 'rocket');

// then play the sounds like so:
sm.play('rocket');

// or play a sound in looping mode:
sm.play('taps', true);

// and to stop a loop:
sm.stop('taps');

// that's it!

License

MIT

Credits

Built (rather hastily) by @HenrikJoreteg for use in And Bang. Which you should totally check out if you work with a team, for anything, ever.

Current Tags

  • 1.0.1                                ...           latest (5 years ago)

7 Versions

  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.5                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.3                                ...           8 years ago
  • 0.0.2                                ...           8 years ago
  • 0.0.1                                ...           8 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (1)