()
| 5 | const sounds = new Map<string, Promise<AudioSound | null>>() |
| 6 | |
| 7 | function getAudio() { |
| 8 | if (audio !== undefined) return audio |
| 9 | try { |
| 10 | const next = Audio.create({ autoStart: false }) |
| 11 | next.on("error", (error: Error, context: AudioErrorContext) => { |
| 12 | console.debug("tui audio error", { error, context }) |
| 13 | }) |
| 14 | audio = next |
| 15 | return next |
| 16 | } catch (error) { |
| 17 | console.debug("failed to create tui audio", { error }) |
| 18 | audio = null |
| 19 | return null |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | export function loadSoundFile(file: string) { |
| 24 | const current = getAudio() |
no test coverage detected