How to play music?

0 favourites
  • 2 posts
From the Asset Store
A complete set of Graphic, User Interface element to build 2D mobile game or PC game.
  • Hi

    I defined the music to be played in start of layout but it won't play until a touch or click be received.

    How can the music be played as soon as the layout starts?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Audio manual article on autoplay restriction :

    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 next opportunity (usually when the user next clicks or touches). However you should be aware of this when designing your game. 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.

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