howler.js v1.1.0

howler.js v1.1.0

Just a few months back, we decided to tackle the challenge of audio in the browser for our upcoming new game, CasinoRPG. What started as a weekend project has turned into a robust javascript audio library that is being used and covered around the world. The response to the library has been overwhelming, and we are excited to have helped fulfill part of our company's mission: advancing the web as the ultimate game platform. I even got asked to write a guest post for Mozilla!

We've received a lot of great feedback and pull requests over the last few months, and we have now marked version 1.1.0 of howler.js as stable. This major new version brings with it countless bug fixes, compatibility improvements and some great new features. Below is a rundown of what you will find in the updated library.

  • New pos3d method that allows for positional audio (Web Audio API only).
  • Multi-playback control system that allows for control of specific play instances when sprites are used. A callback has been added to the play method that returns the soundId for the playback instance. This can then be passed as the optional last parameter to other methods to control that specific playback instead of the whole sound object.
  • Pass the Howl object reference as the first parameter in the custom event callbacks.
  • New optional parameter in sprite defintions to define a sprite as looping rather than the whole track. In the sprite definition array, set the 3rd value to true for looping (spriteName: [pos, duration, loop]).
  • Now all audio acts as a sound sprite internally, which helps to fix several lingering bugs (doesn't affect the API at all).
  • Improved implementation of Web Audio API looping.
  • Improved implementation of HTML5 Audio looping.
  • Issue that caused the fallback to not work when testing locally.
  • Fire onend event at the end of fadeOut.
  • Prevent errors from being thrown on browsers that don't support HTML5 Audio.
  • Various code cleanup and optimizations.

The two most notable additions are pos3d and soundId support. The addition of 3D sound is especially useful in game settings, allowing a whole new world of possibilities when it comes to immersion. You simply pass in the x, y, and z values for the audio source position, and Web Audio API and howler.js will handle the rest.

The soundId support is a really powerful new addition that allows fine-grained control of playback when multiple sounds are played from the same sound source (this is especially useful for sprites). Previously, you only had control over the most recent sound that was played, because the reference to previous play instances was lost. Now, all you have to do is capture the soundId that is passed in a callback from the play() method, and then you can do things like control volume, muting, position, etc for any of the sounds that you have played.

As a side note, please tweet me your apps or sites that are using howler.js. At some point in the near future I plan on putting together a page that features the use of howler.js across the web.