jaysalvat / buzz

Buzz is a small but powerful Javascript library that allows you to easily take advantage of the new HTML5 audio element. It tries to degrade silently on non-modern browsers.
http://buzz.jaysalvat.com
MIT License
1.21k stars 227 forks source link

Don't create the AudioContext unless it is needed #91

Closed holm closed 9 years ago

holm commented 9 years ago

We ran into the following error when many tabs are opened:

Uncaught SyntaxError: Failed to construct 'AudioContext': number of hardware contexts reached maximum (6).

This is caused by the AudioContext always being created, although "webAudioApi" is not enabled.

This PR lazily creates the context. In addition it also catches any errors, so it falls back to the usual way of playing if the limit has been reached.

jaysalvat commented 9 years ago

Thanks a lot! Merged/Released.