function patchAudioContext() {
'use strict';
var triggers = ['mousedown', 'keydown'];
var original = window.AudioContext;
var patched = function AudioContext() {
var ctx = new (Function.prototype.bind.apply(original, [null].concat(arguments)));
if(ctx.state !== 'running') {
var onGesture = function() {
ctx.resume();
triggers.forEach(function(name) { document.removeEventListener(name, onGesture); });
}
triggers.forEach(function(name) { document.addEventListener(name, onGesture); });
}
return ctx;
};
patched.prototype = window.AudioContext;
patched.prototype.constructor = patched;
window.AudioContext = patched;
}