Update to fix mp3 from dean's code
This commit is contained in:
parent
9307b67a59
commit
1cffeb5520
13
src/bootstrap.js
vendored
13
src/bootstrap.js
vendored
@ -1,4 +1,6 @@
|
||||
game.bootstrap = (() => {
|
||||
const image_extensions = ["png", "jpeg", "jpg"];
|
||||
const audio_extensions = ["mp3"];
|
||||
const scripts = [
|
||||
{
|
||||
src: [
|
||||
@ -68,13 +70,18 @@ game.bootstrap = (() => {
|
||||
.then((r) => r.blob())
|
||||
.then((r) => {
|
||||
let asset;
|
||||
if (["png", "jpg", "jpeg"].includes(fileExtension)) {
|
||||
if (image_extensions.includes(fileExtension)) {
|
||||
asset = new Image();
|
||||
} else if (["mp3"].includes(fileExtension)) {
|
||||
} else if (audio_extensions.includes(fileExtension)) {
|
||||
asset = new Audio();
|
||||
}
|
||||
asset.src = URL.createObjectURL(r);
|
||||
asset.onload = () => URL.revokeObjectURL(asset.src);
|
||||
const ready = () => URL.revokeObjectURL(asset.src);
|
||||
if (asset instanceof Image) {
|
||||
asset.onload = ready;
|
||||
} else if (asset instanceof Audio) {
|
||||
asset.oncanplaythrough = ready;
|
||||
}
|
||||
return asset;
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user