JSPM

  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q47196F
  • License MIT

Web Audio Library

Package Exports

  • waud.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (waud.js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

waud logo

Web Audio Library with HTML5 audio fallback.

License haxelib npm version Build Status Code Climate Code Climate Issues

Safari Chrome Firefox Edge Opera
Latest ✓ Latest ✓ Latest ✓ Latest ✓ Latest ✓
  • It is recommended to use same sample rate for all the audio files. Playing different sample rate files can cause issues on some devices.
  • By default, Waud uses 44100 sample rate. If your audio files have a different sample rate then specify it using Waud.preferredSampleRate property.

Installation

npm install waud.js

For haxe users:

haxelib install waud

API Documentation

Example

Example:

var snd = new WaudSound("assets/loop.mp3", { autoplay: false, loop: true, volume: 0.5, onload: playBgSound });

Audio Sprite

Use waudsprite to generate audio sprite.

var audSprite = new WaudSound("assets/sprite.json");
audSprite.play("glass");

Issues

Found any bug? Please create a new issue.

Demo

Usage

Waud.init();
Waud.enableTouchUnlock(touchUnlock);
Waud.autoMute();

var bgSnd = new WaudSound("assets/loop.mp3", {
    "autoplay": false, "loop":true, "volume": 0.5, "onload": playBgSound
});

var snd2 = new WaudSound("assets/sound1.wav", {
    "autoplay": false,
    "loop":true,
    "onload": function (snd) { snd.play(); },
    "onend": function (snd) { console.log("ended"); },
    "onerror": function (snd) { console.log("error"); }
});

//Touch unlock event for iOS devices
function touchUnlock() {
    if (!bgSnd.isPlaying()) bgSnd.play();
}

function playBgSound(snd) {
    if (!snd.isPlaying()) snd.play();
}

Licensing Information

MIT license

This content is released under the MIT License.

Contributor Code of Conduct

Code of Conduct is adapted from Contributor Covenant, version 1.4