mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
play silent audio for browsers that don't implement resume
this jumpstarts the AudioContext
This commit is contained in:
parent
8b92b7469b
commit
0f67791315
2 changed files with 11 additions and 5 deletions
|
@ -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();
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue