# A quick question on sound

**URL:** <https://phaser.discourse.group/t/a-quick-question-on-sound/10904>\
**Category:** Phaser 3\
**Created:** [December 25, 2021, 11:04pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904 "2021-12-25T23:04:05Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![finalmortal](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@finalmortal](https://phaser.discourse.group/u/finalmortal)\
**Post date:** [December 25, 2021, 11:04pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/1 "2021-12-25T23:04:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [December 26, 2021, 10:02pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/2 "2021-12-26T22:02:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![finalmortal](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@finalmortal](https://phaser.discourse.group/u/finalmortal)\
**Post date:** [December 27, 2021, 12:00am UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/3 "2021-12-27T00:00:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Maneneco](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/maneneco/32/6033_2.png) [@Maneneco](https://phaser.discourse.group/u/Maneneco)\
**Post date:** [December 27, 2021, 5:19pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/4 "2021-12-27T17:19:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Maneneco](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/maneneco/32/6033_2.png) [@Maneneco](https://phaser.discourse.group/u/Maneneco)\
**Post date:** [December 27, 2021, 5:31pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/6 "2021-12-27T17:31:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![finalmortal](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@finalmortal](https://phaser.discourse.group/u/finalmortal)\
**Post date:** [December 27, 2021, 9:12pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/7 "2021-12-27T21:12:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Maneneco](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/maneneco/32/6033_2.png) [@Maneneco](https://phaser.discourse.group/u/Maneneco)\
**Post date:** [December 27, 2021, 10:54pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/8 "2021-12-27T22:54:52Z")

</div>

I dont understand what you want to do, can you explain it in another way?

---

<div class="post-metadata">

**Author:** ![Maneneco](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/maneneco/32/6033_2.png) [@Maneneco](https://phaser.discourse.group/u/Maneneco)\
**Post date:** [December 27, 2021, 10:56pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/9 "2021-12-27T22:56:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Maneneco](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/maneneco/32/6033_2.png) [@Maneneco](https://phaser.discourse.group/u/Maneneco)\
**Post date:** [December 28, 2021, 4:13am UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/10 "2021-12-28T04:13:32Z")

</div>

I dont know if this help but:

> **[Autoplay guide for media and Web Audio APIs - Web media technologies | MDN](https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide)**
>
> Automatically starting the playback of audio (or videos with audio tracks) immediately upon page load can be an unwelcome surprise to users. While autoplay of media serves a useful purpose, it should be used carefully and only when needed. In order...

---

<div class="post-metadata">

**Author:** ![finalmortal](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@finalmortal](https://phaser.discourse.group/u/finalmortal)\
**Post date:** [December 28, 2021, 11:06pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/11 "2021-12-28T23:06:18Z")

</div>

Right on

---

<div class="post-metadata">

**Author:** ![Maneneco](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/maneneco/32/6033_2.png) [@Maneneco](https://phaser.discourse.group/u/Maneneco)\
**Post date:** [December 30, 2021, 1:27am UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/12 "2021-12-30T01:27:10Z")

</div>

I found the same issue like you, and the easiest solution and more effective it creating a button to start like this.

 ![Capturar](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/0/0e9eaa3877c47d125222c08fb7a52eff951afd1a.jpeg)

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 1, 2022, 12:54am UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/13 "2022-01-01T00:54:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![finalmortal](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@finalmortal](https://phaser.discourse.group/u/finalmortal)\
**Post date:** [January 14, 2022, 8:58pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/14 "2022-01-14T20:58:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [January 15, 2022, 6:23pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/15 "2022-01-15T18:23:10Z")

</div>

Maybe

```
if (!selectedsoundfile.isPlaying) selectedsoundfile.play();
```

---

<div class="post-metadata">

**Author:** ![finalmortal](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@finalmortal](https://phaser.discourse.group/u/finalmortal)\
**Post date:** [January 16, 2022, 7:23pm UTC](https://phaser.discourse.group/t/a-quick-question-on-sound/10904/16 "2022-01-16T19:23:31Z")

</div>

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.
