mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
177130ec36
addresses #237
26 lines
888 B
JavaScript
26 lines
888 B
JavaScript
define(["Tone/core/Tone", "Tone/core/OfflineContext"], function(Tone){
|
|
|
|
if (Tone.supported){
|
|
|
|
var ua = navigator.userAgent.toLowerCase();
|
|
var isMobileSafari = ua.includes("safari") && !ua.includes("chrome") && ua.includes("mobile");
|
|
if (isMobileSafari){
|
|
//mobile safari has a bizarre bug with the offline context
|
|
//when a BufferSourceNode is started, it starts the offline context
|
|
//
|
|
//deferring all BufferSource starts till the last possible moment
|
|
//reduces the likelihood of this happening
|
|
Tone.OfflineContext.prototype.createBufferSource = function(){
|
|
var bufferSource = this._context.createBufferSource();
|
|
var _native_start = bufferSource.start;
|
|
bufferSource.start = function(time){
|
|
this.setTimeout(function(){
|
|
_native_start.call(bufferSource, time);
|
|
}.bind(this), 0);
|
|
}.bind(this);
|
|
return bufferSource;
|
|
};
|
|
}
|
|
}
|
|
|
|
});
|