threedollarbill

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

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

Share this post


Link to post
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 ).

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks for posting your solution, I'm having the same problem despite using phaser 2.10.4. However, I am using multiple states for my game and I'm not sure where to put the code. In every state?

Share this post


Link to post
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. 

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites
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

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.