summaryrefslogtreecommitdiff
path: root/src/engine/radio.js
blob: 0e2abba53ef44f99b1686a9ee13c5fb7a3c4a7d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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()
        this.bgm = new Audio(file)
        this.bgm.play()
        this.bgm.loop = true
    }

    stopMusic() {
        this.bgm.pause()
    }
}