Sounds on the client
This commit is contained in:
+1
-20
@@ -3,7 +3,7 @@
|
||||
|
||||
import { load_texture, Texture } from "./renderer/mod.ts";
|
||||
|
||||
type Asset = Texture | HTMLAudioElement | string | Record<string, unknown>;
|
||||
type Asset = Texture | string | Record<string, unknown>;
|
||||
|
||||
export class AssetManager {
|
||||
static instance = new AssetManager();
|
||||
@@ -29,25 +29,6 @@ export class AssetManager {
|
||||
});
|
||||
img.src = src;
|
||||
this.loading_promises.push(promise);
|
||||
} else if (src.endsWith(".ogg")) {
|
||||
const audio = new Audio();
|
||||
const promise = new Promise<void>((resolve, reject) => {
|
||||
audio.addEventListener(
|
||||
"canplaythrough",
|
||||
() => resolve(),
|
||||
{ once: true },
|
||||
);
|
||||
audio.addEventListener(
|
||||
"error",
|
||||
() => reject(new Error(`Failed to load audio: ${src}`)),
|
||||
{ once: true },
|
||||
);
|
||||
});
|
||||
|
||||
audio.src = src;
|
||||
audio.load();
|
||||
this.assets[key] = audio;
|
||||
this.loading_promises.push(promise);
|
||||
} else if (src.endsWith(".txt") || src.endsWith(".md") || src.endsWith(".fnt")) {
|
||||
const promise = async () => {
|
||||
const resp = await fetch(src);
|
||||
|
||||
Reference in New Issue
Block a user