bobonthenet Posted February 21, 2017 Share Posted February 21, 2017 I've just about completed my first game that I want to release to the general public. Part of that process is getting it on itch.io and using cocoonjs to package it up to make it native for mobile. The problem is that in certain circumstances the audio will not play. serving it up on my local machine (Ubuntu with a node server) it works on desktop and Android on itch.io (They put it in an iframe) it works on desktop, and iPhone but on android no audio. Tried to package it up with cocoon and tested it on Android again no audio. I don't have an iPhone handy so I'm limited in what testing I can do there. The problem seems to be just on Android though when the game is played through an iframe or packaged into an apk. The game is built around @lukewilde's awesome boilerplate. That thing has really helped my workflow so I hope it isn't part of the problem. I've looked at the build and everything appears as I would expect it. I have also used some code from the official breakout example. So that will look familiar. In the Preloader state I'm Preloading the audio like so: this.game.load.audio('beef', [ './audio/beef.ogg', './audio/beef.mp3' ]); Then in my game state I'm adding a variable for the audio. this.beef = game.add.audio('beef'); Lastly also in the game state the audio is played with: this.beef.play(); I've really been beating my head against the wall trying to figure out what is going on here. I'm hoping it is something simple that I've overlooked. I also don't know how to debug on Android so maybe I just need help with that and I'd figure this out myself. Here is a link to the game on itch.io https://motorcityrobots.itch.io/build-that-wall Here is all the code in Github https://github.com/bobonthenet/BuildThatWallGame Link to comment Share on other sites More sharing options...
rroylance Posted February 21, 2017 Share Posted February 21, 2017 Sounds like the recent change in Chrome for Android; Web Audio user gesture requirement on cross origin iframes on Android... ? https://www.chromestatus.com/feature/6406908126691328 https://github.com/photonstorm/phaser/issues/2913 bobonthenet 1 Link to comment Share on other sites More sharing options...
bobonthenet Posted February 22, 2017 Author Share Posted February 22, 2017 @UncleAcid that was the problem! The fix in https://github.com/photonstorm/phaser/issues/2913 worked for me. I just copied and pasted it into my boot state so it was really easy! I'm using Phaser CE and I don't see this as an issue there should it be added? I don't know if the issues from the Phaser repo carry over or how that works. On second thought I'm going to add it and I apologize here if I should not do so. Link to comment Share on other sites More sharing options...
bobonthenet Posted April 6, 2017 Author Share Posted April 6, 2017 My audio has stopped working again for new builds of my game. I've been making changes but haven't touched the fix I applied in my last comment I can't see that I did anything that should have any impact on the audio. Link to comment Share on other sites More sharing options...
bobonthenet Posted April 7, 2017 Author Share Posted April 7, 2017 OK Audio works just not over bluetooth. I suspect this is not a phaser problem but something to do with the cocoon package. Link to comment Share on other sites More sharing options...
Recommended Posts