Game is not in focus on the strat up

Discussion and feedback on Construct 2

Post » Sun Jun 21, 2015 12:58 pm

Hi!

I have a background music that should play right when the game starts. It works well in Chrome, but when I export my game for Cordova and then run it on a mobile device (Android) the music doesn't play until I touch the screen. Looks like my app is not in focus on start up. What can I do?

Olga

PS I should to read the manual more careful, music doesn't play on 'start of layout':

Mobile limitations
Safari on iOS and Chrome for Android share a limitation in playing music. While sound effects can be played at any time, music is only allowed to start playing when the user touches the screen. This is a limitation in the browsers themselves. As a result, if you play music on the start of layout, you may find in these browsers it does not actually start until the next touch.

Safari on iOS has a further limitation that no audio can play at all until the first touch. In other words, audio starts off muted and the first touch unmutes audio playback.

Usually you do not need to handle this in your events. If you try to play sound or music on 'start of layout', the audio object will automatically queue it up for playback the next time the user touches the screen. 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.
B
10
S
2
Posts: 71
Reputation: 696

Return to Construct 2 General

Who is online

Users browsing this forum: BadMario, MadSpy and 7 guests