Sound not playing unless I click the game

0 favourites
  • 6 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • So, I'm completely new to Construct.

    In one of my experiments, I added a sound that plays when collecting pick-ups. Worked fine. I come back a few days later, I changed a few things and suddenly the sound doesn't play...unless I click on the game...then the last sound will play for some reason.

    (I should add, everything I've made up to this point is keyboard control only.)

    Now, if I click somewhere in the game before I do anything, everything works as it should.

    And I'm trying to be specific when I say, "click on the game." Clicking on the Windows title bar does fix the issue.

    I also added sound to a different project and it has the same issue.

    Any idea what might be wrong?

    Thank you.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • construct.net/en/make-games/manuals/construct-3/plugin-reference/audio

    Autoplay restrictions

    Most modern browsers have a limitation in starting audio playback. To avoid annoying users generally browsing the web, audio playback cannot start until the user interacts with the page, such as touching or clicking it. This is a limitation in the browsers themselves and cannot be worked around. As a result, if you play audio on the start of layout, you may find it does not actually start until the first user interaction.

    Usually you do not need to handle this in your events. If audio cannot be played for any reason, the Audio object will automatically queue it up for playback at the soonest opportunity (usually when the user next clicks or touches). However you should be aware of this when designing your project. For example if the first touch changes layout or stops the music, then the music may never be heard. You may want to start playback then encourage the user to touch the screen with a 'Play' icon or something similar.

    The limitation is specific to web browsers. It does not apply if you publish a mobile app. Further, browsers may lift the limitation in some circumstances, such as if you use the Install or Add to home screen options, or if they identify over time that your web page is regularly used for audio playback that the user wants.

    Although, I'm surprised keyboard input does not count as "user interaction".

  • Thank you for your reply.

    While that makes sense, I don't understand why it worked fine a few days ago and not now. Plus, like you said, I would think keyboard interaction would count.

  • So, it looks like the problem might've been that I was using Firefox. Tried it in Edge and everything worked as expected.

    It still doesn't explain why it worked a few days ago, though.

  • Did you update Firefox? As mentioned, this is a browser limitation, so different browsers can behave differently however they see fit.

  • Clicking isn't the only way the browser detects user input.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)