Avoid touching screen to play audio on each layout change

Get help using Construct 2

Post » Tue May 23, 2017 9:54 am

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!
B
11
S
2
Posts: 163
Reputation: 1,123

Post » Tue May 23, 2017 11:06 am

How do you call the sound in the event system, on layout load or some where else?
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Tue May 23, 2017 11:48 am

@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!
B
11
S
2
Posts: 163
Reputation: 1,123

Post » Tue May 23, 2017 12:29 pm

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.
Like my work? Fallow me on social media, and see my games on the arcade.
B
7
S
5
G
9
Posts: 298
Reputation: 5,367

Post » Tue May 23, 2017 12:35 pm

@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
B
11
S
2
Posts: 163
Reputation: 1,123

Post » Tue May 23, 2017 2:12 pm

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!
B
11
S
2
Posts: 163
Reputation: 1,123

Post » Thu Jun 15, 2017 1:28 pm

Android.... same problem now.....
B
11
S
2
Posts: 163
Reputation: 1,123

Post » Wed Nov 29, 2017 8:00 am

Congrats2u wrote: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.
Last edited by NN81 on Wed Nov 29, 2017 2:59 pm, edited 1 time in total.
sorry my bed English ^_^
B
14
S
7
G
7
Posts: 543
Reputation: 6,063

Post » Wed Nov 29, 2017 11:06 am

@NN81 Thanks for your update :)
B
11
S
2
Posts: 163
Reputation: 1,123


Return to How do I....?

Who is online

Users browsing this forum: draiza and 7 guests