Jump to content

Audio Not Playing


bobonthenet
 Share

Recommended Posts

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

@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

  • 1 month later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...