File size: 849 Bytes
af6912c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
// Call this when it is safe for the abcjs to produce sound. This is after the first user gesture on the page.
// If you call it with no parameters, then an AudioContext is created and stored.
// If you call it with a parameter, that is used as an already created AudioContext.
function registerAudioContext(ac) {
// If one is passed in, that is the one to use even if there was already one created.
if (ac)
window.abcjsAudioContext = ac;
else {
// no audio context passed in, so create it unless there is already one from before.
if (!window.abcjsAudioContext) {
var AudioContext = window.AudioContext || window.webkitAudioContext;
if (AudioContext)
window.abcjsAudioContext = new AudioContext();
else
return false;
}
}
return window.abcjsAudioContext.state !== "suspended";
}
module.exports = registerAudioContext;
|