I'm having a little problem with playing audio in Firefox.
What I'm trying to do is simply play an explosion sound on collision. But the problem is, when collision is happening for the very first time, the explosion sound is played about two seconds after the collision but only for the first time. After the first time the sound is playing fine but never the first time. It is not a big deal but I just don't really like it and I would like to fix it if possible.
I was searching the forum and I tried all the suggestions I found:
-tried exporting the project but didn't solved the problem, I get the same result
-the sounds are preloaded in the first layout and I go to the next layout after all the sounds are preloaded
-the sounds are stored in the sound directory
-deleted the duplicated sound files created by the importer and left only a single sound file (.ogg)
-my browser is up to date
Nothing worked. The only thing I haven't tried yet is to upload the exported HTML5 game to a host such as itch.io...
If I preview in Google Chrome, it works, no problem there, the sound is playing as it should. I have this problem only in Firefox.
Is there anything else I can try to fix this or it is down to Firefox (and Construct 2) to provide better support and compatibility?
Sounds like a browser issue. If it only happens the first time, try playing the sound once (muted) on start of layout?
[quote:1v5vwtnc] try playing the sound once (muted) on start of layout
Thanks a lot, it worked
It could also be that you haven't preloaded that audio file. So playing it silently accomplishes that, but there's an event in the Audio plugin to pre-load specific audio files so they don't have to be loaded in on their first play.
Develop games in your browser. Powerful, performant & highly capable.
[quote:3e737lpy]there's an event in the Audio plugin to pre-load
Yes I tried that but it doesn't work. I even tried to preload the audio in the first layout and go to the next after all the audio is preloaded but still having the problem. The only thing helps (for some reason) if I play the sound once on start of layout.
But I have this problem only in Firefox and only if I play sound at object. If I just "play sound" that works.
It must be something with Firefox and the "play sound at object" action.