Avoid touching screen to play audio on each layout change

0 favourites
  • 9 posts
From the Asset Store
A set of board games to make your day joyful. Play, Enjoy, Relax
  • Hey there!

    This kind of problem is making me really sad. On IOS devices you have to set a touch input on each layout change to play the background music. I builded a ios app with construct2 and cordova and on some layouts i have to play differend music files. But every time there is a new file loaded, you have to trigger it with touching the screen.

    Has someone an idea why? And how to avoid this? Its an app so why the hack is there a behaviour like this? A solution would be awesome!

    Thank you very much!

  • How do you call the sound in the event system, on layout load or some where else?

  • imhotep22

    I have an intro event sheet. There i have a welcome button and if you click on it an intro will be loaded. After the intro is played it loads directly the main menue.

    In the main menue i have the following event:

    https://ibb.co/jy0H7a

    If iam leaving the main menu i call this event: (to stop this sound)

    https://ibb.co/d1WPna

    And on the new layout i call this event again:

    https://ibb.co/j87m0v

    Basically i call only the Play event, and the stop event (before i used the unload event)

    But every time i want to play a new musik sound i have to touch press the screen. Ashley told me, that this has to happen only once and then the sound should play durring the whole game (also for other sound files)

    So something is wrong...i guess (better i hope)

    Please note: Every sound is playing but you can hear it only when you touch the screen. So i tried out to unmute the sounds right at the beginning - but this made no difference.

    Thank you!

  • Okay this is weird, I tried testing similar code on my PC and the music worked perfectly, but if I set pause onfocus in the configuration settings many the sounds does not play until I click on the screen or I move my mouse there. I'm not sure if it works the same on phone(PC and phone are whole different machines), if you have pause onfocus set to yes, disable it and test the game like that.

  • imhotep22

    The thing is: I build the game with cordova for ios because later there has to be an app. And on the app there is no problem with the focus behaviour.

    So there shouldnt be a porblem with the sounds...

    Everything would work fine, if there wouldnt be this weird thing with disabeling the sounds on layout change.

    Basically it is well explained on this site too:

    https://www.ibm.com/developerworks/web/ ... -ioshtml5/

    But there is always the fact, that you only have to trigger it once - and it will work for the whole project, not only for one layout

  • Has someone else the problem that every layout needs to get a new touch input to play the sound? And maybe a solution for this thing?

    Best regards!

  • Android.... same problem now.....

  • Android.... same problem now.....

    hi, i have experienced the same, and to solve i have moved music files into sound folder, seems that sounds dont'need triggered by touch.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • NN81 Thanks for your update

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