We'll utilize a third-party JavaScript library called Howler to add sound effects and music. Howler fixes some native JavaScript audio API issues, such as not being able to overlap audio playbacks on top of each other. We'll learn how to add audio assets, loop audio, and alter the audio's volume.
Google Drive
Background Music:
Sound Effects:
0:00 Credits
1:25 Download assets
2:52 Import assets
6:48 Implement sound effects
13:21 Limit play rates
15:33 Loop audio
16:02 Lower overall volume
Chris,
I am getting
Access to XMLHttpRequest at 'file:///Users/Ed_Tripp/Web/space-invaders/audio/backgroundMusic.wav' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.
And when I play the game it generate 22 errors as well as 11 issues like this one.
The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu
_ @ howler.min.js:2
It seems to slow the performance of the game. Any suggestions?