From 0696b94962a0571fad54844f137dca025df4563b Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Fri, 27 Dec 2024 18:30:10 +0100 Subject: game finished, only assets left --- src/engine/radio.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/engine') diff --git a/src/engine/radio.js b/src/engine/radio.js index d39524a..0e2abba 100644 --- a/src/engine/radio.js +++ b/src/engine/radio.js @@ -1,4 +1,17 @@ export class Radio { + playSound(file) { + let audio = new Audio(file) + audio.play() + } + + playSoundUntilEnd(file) { + let audio = new Audio(file) + return new Promise(res => { + audio.play() + audio.onended = res + }) + } + bgm playMusic(file) { if (this.bgm != undefined) this.bgm.pause() @@ -7,8 +20,7 @@ export class Radio { this.bgm.loop = true } - playSound(file) { - let audio = new Audio(file) - audio.play() + stopMusic() { + this.bgm.pause() } } -- cgit v1.2.3