Simon Game Audio on Mobile

Hey there everyone =)

I think I have finally finished my Simon Game, but have found a weird issue when trying to play the game on my android phone. For some reason, when the cpu plays the button sequence, I hear no audio and can’t figure out why :confused:
My Simon Game
I already submitted my pen but would still like to know what happens here :open_mouth:

Thanks in advance and best regards,


1 Like

I had the same issue with the Pomodoro project. Not sure, but I believe Chrome mobile doesn’t allow autoplay of any sound. I ended up using the Web Audio API.

1 Like

Thanks for your reply Ben. The strange thing is, that I can hear some sound. Like when the cpu plays the sequence I can hear the first sound just fine, but usually not the ones after that. The same thing happens on mobile Firefox too.
Could it still be the same issue you described, even though I hear some audio?

As @BenGitter said, Chrome does not allow applications to play HTML5 audio without an explicit action by the user

1 Like

I have android v. 6.0.1 phone. All sounds working except for the guy on the right platform. No sound made by the guy for directions up and right. I’m not exactly sure what the problem.

1 Like

Oh my god guys, you are absolutely right. Being able to hear some of the CPU*s sounds was throwing me off here. It was indeed the problem you described. Changing “Disable gesture requirement for media playback” in chrome://flags did the trick. Thanks a ton @BenGitter @marzelin @Reggie01

Will have to use WebAudioAPI eventually I guess. : /

1 Like

Well, I’ve got disable gesture requirement enabled, and I don’t think I did it myself so i think it is enabled by default, at least on Android 5.1.1

Yeah it seems the logic is reversed. Although the option is “Disable…”, it has to be disabled to work.

You’re right, but I’ve got it enabled and your app works. @Reggie01 also confirms this behavior.

When did it work? I just added somewhat of a “hacky” solution to my app: When the player clicks on “start” I mute all the sounds of the enemy and play them all, then unmute. This way Chrome thinks I used a “gesture” to play them already so it is ok to play them later on.

I did some testing and this is what I get:
you can’t play a sound immediately when page loads, but it’s completely fine to play a sound in response to button clicks, etc.

Example: // won't work
 // works just fine
    'click', () => // audio plays in response to user action
1 Like

Yeah, that’s what I kinda abuse with my solution. Since the player has to click the “start” button to play the game, I just use that interaction and play all the sounds muted the first time that button is hit. After those sounds were played once “by interaction” it’s apparently fine to use them afterwards. From that point onwards, no click / keyinput is needed for

1 Like

Ah, right. For the initial sequence, the sounds need to be played before a user clicks on any of the buttons.
Nice hack, and great design btw.

1 Like

Thanks a lot @marzelin, glad you like it :slight_smile:

1 Like