test if context is AudioContext before trying to resume

This commit is contained in:
tambien 2019-06-19 10:18:33 -04:00
parent fee62e9173
commit 95142d1a6f

View file

@ -39,8 +39,12 @@ export function setContext(context: BaseAudioContext): void {
* @example
* document.querySelector('#playbutton').addEventListener('click', () => Tone.start())
*/
export function start(): Promise < void> {
return globalContext.resume();
export function start(): Promise <void> {
if (globalContext instanceof AudioContext) {
return globalContext.resume();
} else {
return Promise.resolve();
}
}
/**