Is it possible to play sounds in timer events or do you have to press a button to trigger them?
Most of the tutorials are based on button press or a user gui and i would like to use a timer or something to trigger them without a keypress or gui.
As far as Phaser is concerned you can play sounds any time, but most browsers require one user interaction (click/tap) first before they allow sound.
Is there a way around this limitation? Or is it possible to trigger the sound with a button press in an earlier event with something like a blank period in the sound and skip to a later period in the sound without a user button press to play it somewhat later to kind of emulate another sound being played?
I guess what i wonder is if you can skip or seek into an already playing blank beginning of a sound without a click/tap kind of event.
In p5 have a function you can use to enable this, firefox have this situation solved, and you can enable it on chrome, but it will only work for you. You can add a menu before the game start where you make that first interaction. You can add a sound button disabled at the beginning, and you kinda ignore the problem. or a click to start button
I undertsand your problem but is related with chrome and edge, not with phaser, due to chrome sound policy he does not play until a user action.
The idea i had was to trigger a sound with a silent part and make it somehow replay that silent part until i needed the sound to trigger and then skip to the part of the file with the actual sound. This allows it to be playing silent until i need the sound to trigger without an interaction from the user.
I really need to to be universal for my fan game so i need a simple solution that works for everyone. I’m still not sure though how to skip around the sound in real time without a user interaction just yet but hopefully i can figure it out.
I dont understand what you want to do, can you explain it in another way?
I mean do what i understood you want to play the sound after a bit of time? You can use add event and put a clock on it to trigger the sound when you want.
I dont know if this help but:
Right on
I found the same issue like you, and the easiest solution and more effective it creating a button to start like this.
With Web Audio you don’t usually need a click/tap to play each sound. You just need one interaction and then you play all you want after that.
What method would you use to play a sound in a timer?
Something like this always seems to lock up the game.
function questtime(){
if (beginjackburtonquest == true)
{
selectedsoundfile.play();
}
}
Thanks
Maybe
if (!selectedsoundfile.isPlaying) selectedsoundfile.play();
Not sure what causes it to crash because the sounds play just fine when either the game loads up or i put the same sounds on an interactive button. Putting them on the timer just seem to pause the game because it just stops.
It’s the only issue i’ve had with Phaser so far i tried that method but it just has the same results.