Music autoplay
This commit is contained in:
parent
c814f7715e
commit
769fe3ea9a
5
TODO.md
5
TODO.md
@ -1,11 +1,12 @@
|
||||
## TODO:
|
||||
- finish game image
|
||||
- desktop (landscape) orientation
|
||||
- background music
|
||||
- change quest animation
|
||||
- button hover animation
|
||||
- make docs/
|
||||
|
||||
## done
|
||||
## Done
|
||||
- background music [c814f77]
|
||||
- several correct answer [498ab55]
|
||||
- loading all quest images with loading [b8aa4b6]
|
||||
- splash (loading) screen [b8aa4b6]
|
||||
|
@ -3,5 +3,5 @@
|
||||
"gameVersion": [0, 0, 1],
|
||||
"debug": true,
|
||||
"loaderWidth": 200,
|
||||
"music": "music.mp3"
|
||||
"music": { "src": "music.mp3", "autoplay": true }
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
export function playMusic(config, music) {
|
||||
let request = new XMLHttpRequest();
|
||||
|
||||
request.open("GET", `assets/sfx/${config.music}`, true);
|
||||
request.open("GET", `assets/sfx/${config.music.src}`, true);
|
||||
request.responseType = "arraybuffer";
|
||||
request.onload = function(){
|
||||
music.decodeAudioData(request.response, onDecoded);
|
||||
@ -12,7 +12,9 @@ export function playMusic(config, music) {
|
||||
bufferSource.buffer = buffer;
|
||||
bufferSource.connect(music.destination);
|
||||
bufferSource.loop = true;
|
||||
bufferSource.start();
|
||||
|
||||
if (config.music.autoplay)
|
||||
bufferSource.start();
|
||||
}
|
||||
|
||||
request.send();
|
||||
|
Loading…
Reference in New Issue
Block a user