i built an xCode project with a single WKWebview component to make my game into a mobile app. Everything is working really great but no audio is being played from my PlayCanvas in the WkWebview. Any tips for this? Im not really sure how the audio works under the hood so hard for me to trouble shoot
It seems you can configure the wkwebview to require user interaction for audio ON/OFF. This image is from Xcode storyboard settings but there should also be possible to configure that properties in code also.
Hmm yeah I actually tested with a different pc game (SWOOOP - PLAYCANVAS) instead off mine and it plays the sound, so i think my xcode project is not at fault here. I dont play sound until after the user logs in and goes to other scenes so theres for sure user interaction first. Im not really sure what the issue could be
Hey so i found the issue,
My server was feeding me game files with names like:
As you can see - the file extension is “.mp320220120-15-sjzogl”, this still played on chrome and firefox but not on Safari or WKWebview. I corrected my server to serve only .mp3 without the additional characters and it worked!
Guess it was a safari issue with my file type and not really anything to do with playcanvas
As a follow up - this didn’t solve my mobile safari problem, i thought it did but it did because my login button triggering music worked - but later when sound affects from game events triggered sound it was still broken.
After some research it seems that with
new Audio() functions, they need to be played/triggered from within the context of a user interaction event (like click or touchdown)
Long story short - i ended up using Playcanvas’ Sound component and it worked great, if you want sound in your game don’t use html
new Audio(), just use Playcanvas’ sound component system.