I have developed a basic test app using Phaser 3 (written in Typescript and transpiled with rollup
) and am utilizing Capacitor to convert it into an iOS application on my Mac.
This excerpt highlights the key functionality of the app:
function preload () {
this.load.audio('boom', ['boom.mp3', 'boom.ogg', './boom-44100.ogg', './boom-44100.mp3']);
this.load.image('wizball', './wizball.png');
}
function create () {
const image = this.add.image(400, 300, 'wizball').setInteractive();;
this.boom = this.sound.add('boom');
image.on('pointerup', () => {
this.boom.play();
});
}
The app displays an image of a wizball, and upon clicking it, you should hear a "boom" sound.
Here is what happens when I run it:
- Using
npm run watch
and accessing http://localhost:10001 in a browser on my Mac, everything functions correctly; - Loading
index.html
from thedist/
directory in a browser on my Mac results in successful operation; - Accessing on either my Mac or iPad works as expected;
- However, after building an iOS app in Xcode using Capacitor, clicking the image yields no sound at all.
These are the steps followed to generate the iOS app:
npm i
npm run watch
npx cap add ios
npx cap copy ios
npx cap open ios
The console log in Xcode showcases the following error message:
Error: There is no audio asset with key "boom" in the audio cache
⚡️ URL: capacitor://localhost/game.js
I find it perplexing because the image asset loads without any issues. Both boom.mp3
and wizball.png
are present in the ios/App/public/
directory.
To access the complete code along with instructions for reproduction, visit: https://github.com/joostvunderink/soundtest Ensure that you have node 10+ and Xcode (with at least one virtual device configured) installed to build the iOS app.
What could I be missing?