Jump to content

Game's sounds suddenly stopped playing, and browser console says "The AudioContext was not allowed to start."


threedollarbill
 Share

Recommended Posts

Hi, the sound on my games suddenly cannot be heard. I'm not sure what's going on.

When I look at the console (Chrome), it shows a message saying "The AudioContext was not allowed to start. It must be resume (or created) after a user gesture on the page.".

Does anybody have an idea of what's going on? How can I get the sounds play again?

console_error.png

Link to comment
Share on other sites

With Phaser CE 2.10.3 and the latest chrome release, this is still happening with our game ( I did look through the source code from that version, and it looked a lot like this was supposed to be handled automatically ).

Link to comment
Share on other sites

4 hours ago, threedollarbill said:

Actually, i just tested 2.10.4 now and it doesn't seem to handle the audiocontext issue. I still get no sound despite clicking on the canvas.

Check the console? There's actually a flaw in Phaser's method. If it fails you'll see a second warning traced to resumeWebAudio.

Link to comment
Share on other sites

Do what I did: don't put it in a state, or in a game input event at all. Simply attach it to a click event on the body or html elements using jQuery. you know the user is going to click body or html eventually. 

Sucks that i can no longer auto-play intro music. On the other hand, I completely understand why Google implemented this as spammers take advantage of auto-play. 

Link to comment
Share on other sites

8 hours ago, Zampano said:

Thanks for posting your solution, I'm having the same problem despite using phaser 2.10.4.

Check whether the audio context is still suspended (game.debug.sound shows this).

Phaser v2.10.5 fixed a flaw in this process also.

Link to comment
Share on other sites

6 hours ago, samme said:

Check whether the audio context is still suspended (game.debug.sound shows this).

Phaser v2.10.5 fixed a flaw in this process also.

One of my games was using older version of the Phaser2 library, and simply replacing it with the latest v2.10.5 version fixed it :) Didn't even have to change my game script.

Link to comment
Share on other sites

  • 4 weeks later...

So I have updated some games successfuly, but I realised other games still do not play audio on Android. 

Actually everything works fine if you visit the game directly, but if you embed the game in iframe, it does not work. I use this code by threedollarbill

        game.input.onDown.addOnce(() => {
        game.sound.context.resume();
        });

I don't see any reason for this? Any ideas? If I use Phaser v2.10.5 , it works but the game is too slow. If I just replace phaser.min.js, the game is definately much slower on mobile. I expected the new version to be better than previous versions...

Link to comment
Share on other sites

  • 1 year later...
On 5/8/2018 at 11:27 PM, feudalwars said:

With jQuery:


$('html,body').on('click', function() {

    if (!inGame) {
        if (game != undefined) {
            game.sound.context.resume();
        }
    }

});

 

Where does `inGame` come from? Otherwise with this code as it stands this is what's produced:Uncaught ReferenceError: inGame is not defined

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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