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 My Simon Game
I already submitted my pen but would still like to know what happens here
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.
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?
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.
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. : /
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:
audio.play() // won't work
// works just fine
document
.querySelector('.play')
.addEventListener(
'click', () => audio.play() // audio plays in response to user action
)
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 audio.play().