diff --git a/docs/simple.js b/docs/simple.js index 968a766..04e8264 100644 --- a/docs/simple.js +++ b/docs/simple.js @@ -194,6 +194,7 @@ class Emulator { this.cancelAnimationFrame(); clearInterval(this.rewindIntervalId); this.rewind.destroy(); + this.audio.destroy(); this.module._emulator_delete(this.e); this.module._free(this.romDataPtr); } @@ -658,6 +659,17 @@ class Audio { if (!this.started) { return; } Audio.ctx.resume(); } + + destroy() { + if (this.boundStartPlayback) { + window.removeEventListener('keydown', this.boundStartPlayback, true); + window.removeEventListener('click', this.boundStartPlayback, true); + window.removeEventListener('touchend', this.boundStartPlayback, true); + this.boundStartPlayback = null; + } + this.buffer = null; + this.started = false; + } } Audio.ctx = new AudioContext;