diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-27 18:30:10 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-27 18:30:10 +0100 |
commit | 0696b94962a0571fad54844f137dca025df4563b (patch) | |
tree | 8aeff72e8fc46a7dab2b2f556febd962e3f67e4b /src/engine | |
parent | 474a7253b6b67e2ed33936f6b633587d5d304b66 (diff) |
game finished, only assets left
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/radio.js | 18 |
1 files changed, 15 insertions, 3 deletions
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() } } |