play silent audio for browsers that don't implement resume

this jumpstarts the AudioContext
This commit is contained in:
tambien 2018-05-17 18:38:40 -04:00
parent 8b92b7469b
commit 0f67791315
2 changed files with 11 additions and 5 deletions

View file

@ -18,6 +18,12 @@ define(["Tone/core/Tone", "Tone/shim/OfflineAudioContext"], function(Tone){
//not functionally equivalent
if (!AudioContext.prototype.resume){
AudioContext.prototype.resume = function(){
//play some silent audio to jumpstart the context
var buffer = this.createBuffer(1, 1, this.sampleRate);
var source = this.createBufferSource();
source.buffer = buffer;
source.connect(this.destination);
source.start(0);
return Promise.resolve();
};
}

View file

@ -111,13 +111,13 @@ module.exports = function(config){
flags : ["--no-sandbox", "--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--autoplay-policy=no-user-gesture-required"]
},
HeadlessFirefox : {
base : "Firefox",
base : "Firefox",
flags : ["-headless"],
prefs : {
"media.navigator.permission.disabled" : true,
prefs : {
"media.navigator.permission.disabled" : true,
"focusmanager.testmode" : true
}
}
}
}
}
};