JavaScript音频库:howler.js

jopen 12年前

howler.js 是一个新的 JavaScript 库用于处理 Web 的音频,该库最初是为一个 HTML5 游戏引擎所开发,但也可用于其他的 Web 项目。

  • Defaults to Web Audio API
  • Falls back to HTML5 Audio
  • Supports multiple file formats to support all browsers
  • Automatic caching for Web Audio API
  • Implements cache pool for HTML5 Audio
  • Per-sound and global mute/unmute and volume control
  • Playback of multiple sounds at the same time
  • Easy sound sprite definition and playback
  • Fade in/out sounds
  • Methods can be chained
  • Uses no outside libraries, just pure Javascript
  • Lightweight, 7kb filesize (2kb gzipped)

JavaScript音频库:howler.js

示例代码:

var sound = new Howl({    urls: ['sound.mp3', 'sound.ogg', 'sound.wav'],    autoplay: true,    loop: true,    volume: 0.5,    onend: function() {      alert('Finished!');    }  });

项目主页:http://www.open-open.com/lib/view/home/1359701559072