From f87fb483c70ace7025736a1bba4bc10c44609b6d Mon Sep 17 00:00:00 2001 From: Marks Polakovs Date: Fri, 1 May 2020 10:56:22 +0200 Subject: [PATCH] Take two, this time it doesn't brooke everything --- src/mixer/state.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mixer/state.ts b/src/mixer/state.ts index 1d8ee6c..eddbde3 100644 --- a/src/mixer/state.ts +++ b/src/mixer/state.ts @@ -19,6 +19,7 @@ const playerGainTweens: Array<{ tweens: Between[]; }> = []; const loadAbortControllers: AbortController[] = []; +const lastObjectURLs: string[] = []; type PlayerStateEnum = "playing" | "paused" | "stopped"; type PlayerRepeatEnum = "none" | "one" | "all"; @@ -297,7 +298,11 @@ export const load = ( const playerInstance = await audioEngine.createPlayer(player, objectUrl); - URL.revokeObjectURL(objectUrl); + // Clear the last one out from memory + if (typeof lastObjectURLs[player] === "string") { + URL.revokeObjectURL(lastObjectURLs[player]); + } + lastObjectURLs[player] = objectUrl; playerInstance.on("loadComplete", (duration) => { console.log("loadComplete");