summaryrefslogtreecommitdiff
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/radio.js18
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()
}
}